@param EntityInterface $entity

@return bool
@throws Exception
171179
public function validate(EntityInterface $entity)
    {
        if (!$entity instanceof Notification) {
            throw new Exception('Entity to validate must be an instance of "Notification"');
        }

        $this->validateMessage($entity->getMessage());
        $this->validateLevel($entity->getLevel());
        $this->validateNamespace($entity->getNamespace());
        $this->validateOrigin($entity->getOrigin());
        $this->validateReportedAt($entity->getReportedAt());

        $errors = $this->getErrors();
        return empty($errors);
    }
1158958
public function initialiseEntity(EntityInterface $entity): void
    {
        $entity->ensureMetaDataIsSet($this->entityManager);
        $this->addListenerToEntityIfRequired($entity);
        $this->entityDependencyInjector->injectEntityDependencies($entity);
        $debugInitMethod = $entity::getDoctrineStaticMeta()
                                  ->getReflectionClass()
                                  ->getMethod(UsesPHPMetaDataInterface::METHOD_DEBUG_INIT);
        $debugInitMethod->setAccessible(true);
        $debugInitMethod->invoke($entity);
    }
313830
public function supportsEntity(EntityInterface $entity): bool
    {
        foreach ($this->mappers as $mapper) {
            if ($mapper->supportsEntity($entity)) {
                return true;
            }
        }

        return false;
    }
412538
protected function registerEntity(EntityInterface $entity)
    {
        Orm::getRepository($this->getEntityClassName())
            ->getIdentityMap()
            ->set($entity);
        return $this;
    }
644778
public function validate(EntityInterface $entity)
    {
        if (!$entity instanceof Role) {
            throw new Exception(
                sprintf('The Entity to validate must be an instance of %s', Role::class)
            );
        }

        $this->validateRole($entity->getRole());
        $this->validateLabel($entity->getLabel());
        $this->validateUserCreated($entity->getUserCreated());
        $errors = $this->getErrors();

        return empty($errors);
    }
177492
protected function _validation(EntityInterface $entity)
    {
        $validator = new Validator();
        $hasErrors = false;

        foreach ($this->_attributesForEntity($entity) as $attr) {
            $field = $this->_prepareMockField($entity, $attr);
            $result = $field->validate($validator);

            if ($result === false) {
                $this->attachEntityFields($entity);

                return false;
            }

            $errors = $validator->errors($entity->toArray(), $entity->isNew());
            $entity->errors($errors);

            if (!empty($errors)) {
                $hasErrors = true;
                if ($entity->has('_fields')) {
                    $entityErrors = $entity->errors();
                    foreach ($entity->get('_fields') as $field) {
                        $postData = $entity->get($field->name);
                        if (!empty($entityErrors[$field->name])) {
                            $field->set('value', $postData);
                            $field->metadata->set('errors', (array)$entityErrors[$field->name]);
                        }
                    }
                }
            }
        }

        return !$hasErrors;
    }
1267612
protected function isLockableEntityLocked(LockableEntityInterface $entity)
    {
        /** @var EntityVersionLockService $entityVersionLockService */
        $entityVersionLockService = $this->container->get('kunstmaan_entity.admin_entity.entity_version_lock_service');

        return $entityVersionLockService->isEntityBelowThreshold($entity) && $entityVersionLockService->isEntityLocked(
                $this->getUser(),
                $entity
            );
    }
796901
public function insert(EntityInterface $entity)
	{
		$projectId = $entity->getProjectId();
		$name = $entity->getName();
		$desc = $entity->getDescription();
		$tags = $entity->getTags();
		$started = $entity->getStarted();
		$startedObj = is_null($started) ? new \DateTime() : $started;
		$startedStr = $startedObj->format(\DateTime::RFC3339);
		$stopped = $entity->getStopped();
		$stoppedObj = is_null($stopped) ? null : (($stopped instanceof \DateTime) ? $stopped : new \DateTime($stopped));
		$stoppedStr = ($stopped instanceof \DateTime) ? $stoppedObj->format(\DateTime::RFC3339) : '';

		$table = self::TABLE_NAME;
		$stmt = $this->pdo->prepare(<<<EOT
INSERT INTO `$this->tableName` (ProjectId, Name, Description, Tags, Started, Stopped) 
VALUES ( :projectId, :name , :desc , :tags , :started , :stopped );
EOT
		);
		$stmt->bindParam(':projectId', $projectId, \PDO::PARAM_INT);
		$stmt->bindParam(':name', $name, \PDO::PARAM_STR);
		$stmt->bindParam(':desc', $desc, \PDO::PARAM_STR);
		$stmt->bindParam(':tags', $tags, \PDO::PARAM_STR);
		$stmt->bindParam(':started', $startedStr, \PDO::PARAM_STR);
		$stmt->bindParam(':stopped', $stoppedStr);
		$res = $stmt->execute();

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

		return $this->prepareEntity(array(
			'ActivityId' => $this->pdo->lastInsertId(),
			'ProjectId' => $projectId,
			'Name' => $name,
			'Description' => empty($description) ? null : $description,
			'Tags' => empty($tags) ? null : $tags,
			'Started' => $started,
			'Stopped' => $stopped
		));
	}
124694
public function saveEntity(EntityInterface $entity)
    {
        $checkEntity = $this->getTable()->fetchEntityById($entity->getIdentifier());

        if ($checkEntity) {
            return $this->getTable()->updateEntity($entity);
        } else {
            return $this->getTable()->insertEntity($entity);
        }
    }
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;
    }
317386
public function updateEntity(EntityInterface $entity)
    {
        $update = $this->getSql()->update();
        $update->set($this->getHydrator()->extract($entity));
        $update->where->equalTo($this->getPrimaryKey(), $entity->getIdentifier());

        try {
            $this->updateWith($update);
        } catch (RuntimeException $e) {
            return false;
        }

        return true;
    }
896247
public function getEntityPostfixByInterfaceName($entityInterfaceName)
    {
        if (false === $this->hasEntityPostfixByInterfaceName($entityInterfaceName)) {
            $errMsg = sprintf('Error build entity postfix for %s', $entityInterfaceName);
            throw new Exception\ErrorBuildEntityPostfixException($errMsg);
        }

        return $this->interfaceNameToEntityPostfix[$entityInterfaceName];
    }
831544
public function save(SaveEntityInterface $entity)
    {
        $entity = $this->persist($entity);
        $this->flush();

        return $entity;
    }
727727
public function delete(EntityInterface $entity, array $commandOptions = array())
    {
        $this->dispatchEntityRequestEvent(Events::ENTITY_PRE_DELETE, $entity);

        $commandOptions += array(
            'TableName' => $this->getEntityTable($entity),
            'Key'       => $this->formatKeyCondition($entity),
        );

        $model = $this->dynamoDb->deleteItem($commandOptions);

        $this->dispatchEntityResponseEvent( Events::ENTITY_POST_DELETE, $entity, $model);
        return true;
    }
558707
protected function findAndRemove(EntityInterface $entity = null)
    {
        if (null == $entity) {
            return $entity;
        }

        /** @var EntityInterface $existent */
        foreach ($this->data as $key => $existent) {
            if ($existent->getId() == $entity->getId()) {
                parent::remove($key);
                $this->getEmitter()
                    ->emit(
                        new EntityRemoved(
                            $entity,
                            ['collection' => $this]
                        )
                    );
                break;
            }
        }
        
        return $entity;
    }
215869
public function getSaverForEntity(
        EntityInterface $entity
    ): EntitySaverInterface {
        $fqn = $this->getEntityNamespace($entity);

        return $this->getSaverForEntityFqn($fqn);
    }
1268183
public function getPersisterForEntity(EntityInterface $entity)
    {
        return $this->isNewEntity($entity) ? $this->createPersister() : $this->createUpdateQuery();
    }