@param IEntity $entity

@return Row|null
324518
public function getPersistedRowFor(IEntity $entity)
    {
        $hash = spl_object_hash($entity);

        return isset($this->persistedEntityRows[$hash]) ? $this->persistedEntityRows[$hash] : null;
    }
632851
public function delete(EntityInterface $entity)
    {
        $this->entity = $entity;
        $primaryKey = $this->getDescriptor()->getPrimaryKey()->getName();
        $table = $this->getDescriptor()->getTableName();
        $sql = Sql::createSql($this->getAdapter());

        $this->triggerBeforeDelete($entity);

        $this->setUpdateCriteria(
            $sql->delete($table),
            $primaryKey,
            $table
        )->execute();

        $this->triggerAfterDelete($entity);
        $this->removeEntity($entity);
        return $this;
    }
78573
protected function _getScope(EntityInterface $entity)
    {
        $scope = [];
        $config = $this->getConfig();

        // If scope are specified and data for all scope fields is not
        // provided we cannot calculate new order
        if ($config['scope']) {
            $scope = $entity->extract($config['scope']);
            if (count($scope) !== count($config['scope'])) {
                return false;
            }

            // Modify where clauses when NULL values are used
            foreach ($scope as $field => $value) {
                if (is_null($value)) {
                    $scope[$field . ' IS'] = $value;
                    unset($scope[$field]);
                }
            }
        }

        return $scope;
    }
248453
public function setEntity(Entity $entity)
    {
        $this->each(
            function(Record $record) use ($entity) {
                $record->setEntity($entity);
                $record->setEntityClass(get_class($entity));
            }
        );

        return $this;
    }
492161
public function getLoadedEntity(NodeInterface $entity): NodeInterface
    {
        $class = ClassUtils::getClass($entity);
        if (isset(self::$deferred[$class][$entity->getId()]) && self::$deferred[$class][$entity->getId()] instanceof NodeInterface) {
            return self::$deferred[$class][$entity->getId()];
        }

        //fallback
        return $entity;
    }
878442
public function encryptEntity(EntityInterface $entity): EntityInterface
    {
        if (!$this->isEncryptable($entity)) {
            return $entity;
        }

        $fields = $this->getFields();
        $encryptionKey = $this->getConfig('encryptionKey');
        $base64 = $this->getConfig('base64');
        $table = $this->getTable();

        $patch = [];
        foreach ($fields as $name => $field) {
            if (!$table->hasField($name)) {
                continue;
            }
            $value = $entity->get($name);
            if ($value === null || is_resource($value)) {
                continue;
            }
            $encrypted = Security::encrypt($value, $encryptionKey);
            if ($base64 === true) {
                $encrypted = base64_encode($encrypted);
            }
            $patch[$name] = $encrypted;
        }

        if (!empty($patch)) {
            $accessible = array_fill_keys(array_keys($patch), true);
            $entity = $table->patchEntity($entity, $patch, [
                'accessibleFields' => $accessible,
            ]);
        }

        return $entity;
    }
561088
public function update(EntityInterface $entity)
	{
		$sql = <<<EOT
UPDATE `$this->tableName` 
SET 
	`ProjectId` = :projectId , 
	`Name` = :name , 
	`Description` = :description , 
	`Tags` = :tags , 
	`Started` = :started , 
	`Stopped` = :stopped 
WHERE `ActivityId` = :id 
EOT;

		$stmt = $this->pdo->prepare($sql);
		$stmt->bindParam(':id', $entity->getActivityId(), \PDO::PARAM_INT);
		$stmt->bindParam(':projectId', $entity->getProjectId(), \PDO::PARAM_INT);
		$stmt->bindParam(':name', $entity->getName(), \PDO::PARAM_STR);
		$stmt->bindParam(':description', $entity->getDescription(), \PDO::PARAM_STR);
		$stmt->bindParam(':tags', $entity->getTags(), \PDO::PARAM_STR);
		$stmt->bindParam(':started', $entity->getStartedRfc3339(), \PDO::PARAM_STR);
		$stmt->bindParam(':stopped', $entity->getStoppedRfc3339(), \PDO::PARAM_STR);
		$res = $stmt->execute();

		if ($res === false || $stmt->rowCount() !== 1) {
			return false;
		}

		return $entity;
	}
161491
public function getEntityModel(EntityInterface $entity): string
    {
        $source = $entity->source();
        if (substr($source, -5) == 'Table') {
            $source = substr($source, 0, -5);
        }

        return $source;
    }
61377
protected function _getTableEntity($entity = '') {
        /** @var $class \Gcs\Framework\Core\Orm\Entity\Entity */

        $entity = ucfirst(preg_replace_callback("/(?:^|_)([a-z])/", function ($matches) {
            return strtoupper($matches[1]);
        }, $entity));

        $className = '\Orm\Entity\\' . ucfirst($entity);

        if (class_exists($className)) {
            return self::Entity()->$entity();
        }
        else {
            throw new MissingEntityException('The Entity ' . $entity . ' does not exist');
        }
    }
99052
public function deleteEntityById($entity, $id)
    {
        $tbl = $this->_resource->getTableName($entity);
        $where = [];
        foreach ($id as $field => $value) {
            $where["`$field`=?"] = $value;
        }
        $result = $this->_conn->delete($tbl, $where);
        return $result;
    }
546477
public function load(Entity $entity)
    {
        /** @var \Slick\Orm\Sql\Select $sql */
        $sql = call_user_func_array(
            array($this->getRelatedEntity(), 'find'),
            []
        );
        $pmk = $this->getEntity()->getPrimaryKey();
        $table = Entity\Manager::getInstance()->get($this->getRelatedEntity())
            ->getEntity()->getTableName();
        $sql->where(
            [
                "{$table}.{$this->getForeignKey()} = :id" => [
                    ':id' => $this->getEntity()->$pmk
                ]
            ]
        );
        return $sql->first();
    }
1322532
private function resolve($entity)
    {
        foreach ($this->namespaces as $namespace) {
            $className = $namespace . '\\' . ucfirst($entity);
            if (class_exists($className)) {
                return $className;
            }
        }
        return null;
    }
68212
public function getEntityMetadata($entity)
    {
        if (!$this->isManagedByDoctrine($entity)) {
            return null;
        }

        $cacheKey = 'metadata';
        $entity   = $this->getEntityClassFull($entity);
        $metadata = $this->getFromCache($entity, $cacheKey);

        if (false !== $metadata) {
            return $metadata;
        }

        $metadata = $this->entityManager->getClassMetadata($entity);
        $this->cache[$metadata->getName()][$cacheKey] = $metadata;

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

        return !empty($hlblock['ID']) ? $hlblock['ID'] : null;
    }
215869
public function getSaverForEntity(
        EntityInterface $entity
    ): EntitySaverInterface {
        $fqn = $this->getEntityNamespace($entity);

        return $this->getSaverForEntityFqn($fqn);
    }
48421
public static function delete($entity): ResultInterface
    {
        $className = \get_class($entity);
        list($table, , , $fields) = self::getFields($entity, 3);
        $instance = self::getInstance($className);

        $query = Query::table($table)->selectInstance($instance);
        foreach ($fields ?? [] as $column => $value) {
            $query->where($column, $value);
        }

        return $query->delete();
    }
540240
public function findOrCreateFor(AbstractEntity $entity)
    {
        $seo = $this->findFor($entity);

        if (is_null($seo)) {
            $seo = new Seo();
            $seo->setRef($entity);
        }

        return $seo;
    }