@param string $entity

@return mixed
166593
protected function HLGetIdByCode($entity)
    {
        $filter = [
            'filter' => ['=NAME' => $entity],
        ];
        $hlblock = HighloadBlockTable::getRow($filter);

        return !empty($hlblock['ID']) ? $hlblock['ID'] : null;
    }
467947
public function serialize($entity)
    {
        return array($this->getName().'.'.$this->_parent_key => $entity->get($this->_parent_key));
    }
300300
private function getLoader($entity)
    {
        $entityClass = get_class($entity);

        if ($this->unsupportedClasses->containsKey($entityClass)) {
            return;
        }
        if ($this->loaders->containsKey($entityClass)) {
            return $this->loaders->get($entityClass);
        }
        foreach ($this->loaders as $handledClass => $loader) {
            if (is_a($entity, $handledClass)) {
                $this->loaders->set($entityClass, $loader);

                return $loader;
            }
        }

        $this->unsupportedClasses->set($entityClass, false);
    }
410011
public function getPositionFieldByEntity($entity)
	{
		if (is_object($entity)) {
			$entity = \Doctrine\Common\Util\ClassUtils::getClass($entity);
		}

		if (isset($this->positionField['entities'][$entity])) {
			return $this->positionField['entities'][$entity];
		} else {
			return $this->positionField['default'];
		}
	}
536796
public function getLevel($entity)
    {
        $primaryKey = $this->_getPrimaryKey();
        $id = $entity;
        if ($entity instanceof EntityInterface) {
            $id = $entity->get($primaryKey);
        }
        $config = $this->getConfig();
        $entity = $this->_table->find('all')
            ->select([$config['left'], $config['right']])
            ->where([$primaryKey => $id])
            ->first();

        if ($entity === null) {
            return false;
        }

        $query = $this->_table->find('all')->where([
            $config['left'] . ' <' => $entity[$config['left']],
            $config['right'] . ' >' => $entity[$config['right']],
        ]);

        return $this->_scope($query)->count();
    }
1068997
public function getFieldMapping($entity)
    {
        $fields = $this->getPropertiesByType($entity, self::FIELD_CLASS);

        $mapping = [];
        foreach ($fields as $field) {
            $mapping[$field->getNameWithAlias()] = $field->name;
        }

        $id = $this->getIdentifier($entity);
        $mapping['id'] = $id->name;

        return $mapping;
    }
1345472
protected function parseToDocument($entity)
    {
        $schemaMapper = $this->getSchemaMapper();
        $parsedDocument = $schemaMapper->map($entity);

        if (is_object($entity)) {
            foreach ($parsedDocument as $field => $value) {
                $entity->$field = $value;
            }
        }

        return $parsedDocument;
    }
184195
public function remove($entity)
    {
        if ($entity->isValid() && is_numeric($entity['id']->value)) {
            $query = 'DELETE FROM `' . $this->tableName . '` WHERE `id`=:id';
            $statement = $this->database->prepare($query);
            $statement->bindParam(':id', $entity['id']->value);
            return $statement->execute();
            // #@todo throw and exception if $stmt->errorInfo() has an error?
            // var_dump($stmt->errorInfo());
        } else {
            // #@todo: handle invalid entity
            // #@todo: handle invalid id
        }
    }
621790
public function & getEntityChangeSet($entity)
    {
        $oid  = spl_object_id($entity);
        $data = [];

        if (! isset($this->entityChangeSets[$oid])) {
            return $data;
        }

        return $this->entityChangeSets[$oid];
    }
237919
protected function getClassKey($entity)
    {
        $parts = explode('.', $entity);
        $class = array_shift($parts);

        // Ensure the `.ss` suffix gets added to the top level class rather than the key
        if (count($parts) > 1 && reset($parts) === 'ss') {
            $class .= '.ss';
            array_shift($parts);
        }
        $key = implode('.', $parts);
        return array($class, $key);
    }
234225
public function getPositionFieldByEntity($entity)
    {
        if (is_object($entity)) {
            $entity = ClassUtils::getClass($entity);
        }

        if (isset($this->positionField['entities'][$entity])) {
            return $this->positionField['entities'][$entity];

        } else {
            return $this->positionField['default'];
        }
    }
899822
private function getContentFromEntity( $entity ) {
		switch ( $entity->getType() ) {
			case Item::ENTITY_TYPE:
				return new ItemContent( $entity );
			case Property::ENTITY_TYPE:
				return new PropertyContent( $entity );
			default:
				throw new RuntimeException( 'I cant get a content for this type of entity' );
		}
	}
813107
public function getOriginalEntityData($entity)
    {
        $oid = spl_object_hash($entity);

        if (isset($this->originalEntityData[$oid])) {
            return $this->originalEntityData[$oid];
        }

        return array();
    }
710471
public function getConfigFromEntity($entity) {
        $parameters = array();
        $parameters['_onlyConf'] = true;
        return $this->generate($entity,null,$parameters);
    }
1229189
private function getRepository($entity)
    {
        if (!array_key_exists($entity, $this->repositories)) {
            throw new \InvalidArgumentException("'$entity' is not a valid repository. One of [".implode(', ', array_keys($this->repositories)).'] is expected.');
        }

        return $this->repositories[$entity];
    }
442893
function getValue($entity)
    {
        $raw = $this->property->getValue($entity);

        switch ($this->format)
        {
            case 'scalar':
                return $raw;

            //Serialize classes and arrays before putting them in the DB
            case 'object':
            case 'array':
                return serialize($raw);

            //Json encode before putting into DB
            case 'json':
                return json_encode($raw);

            //Format the date correctly before putting in DB
            case 'date':

                if ($raw)
                {
                    $value = clone $raw;
                    $value->setTimezone(new \DateTimeZone('UTC'));
                    return $value->format('Y-m-d H:i:s');
                }

                else
                {
                    return null;
                }
        }

        return null;
    }
1116027
public function transform($entity)
    {
        if (null === $entity) {
            return '';
        }
        if (!is_subclass_of($entity, $this->entityClass)) {
            throw new \InvalidArgumentException(sprintf(
                'Unsupported entity "%s" into "%s" loader.',
                get_class($entity),
                __CLASS__
            ));
        }

        return $entity->getId();
    }