示例#1
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param string $identifier
  * @return object
  */
 public function execute($entityType, $entity, $identifier)
 {
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $entityData = $this->readRow->execute($entityType, $identifier);
     $entity = $hydrator->hydrate($entity, $entityData);
     return $entity;
 }
示例#2
0
 /**
  * @param object $entity
  * @param array $arguments
  * @return object
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $entityType = $this->typeResolver->resolve($entity);
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $arguments = array_merge($hydrator->extract($entity), $arguments);
     $this->deleteRow->execute($entityType, $arguments);
     return $entity;
 }
示例#3
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param array $arguments
  * @return object
  */
 public function execute($entityType, $entity, $arguments = [])
 {
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $entityData = $this->updateRow->execute(
         $entityType,
         array_merge($hydrator->extract($entity), $arguments)
     );
     $entity = $hydrator->hydrate($entity, $entityData);
     return $entity;
 }
示例#4
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param array $arguments
  * @return object
  */
 public function execute($entityType, $entity, $arguments = [])
 {
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $entityData = array_merge($hydrator->extract($entity), $arguments);
     $actions = $this->attributePool->getActions($entityType, 'create');
     foreach ($actions as $action) {
         $action->execute($entityType, $entityData);
     }
     $entity = $hydrator->hydrate($entity, $entityData);
     return $entity;
 }
示例#5
0
 /**
  * @param object $entity
  * @param array $arguments
  * @return bool
  * @throws \Exception
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entity, $arguments = [])
 {
     $entityType = $this->typeResolver->resolve($entity);
     $metadata = $this->metadataPool->getMetadata($entityType);
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
     $entityData = $hydrator->extract($entity);
     if (!isset($entityData[$metadata->getIdentifierField()])) {
         return false;
     }
     return (bool) $connection->fetchOne($connection->select()->from($metadata->getEntityTable(), [$metadata->getIdentifierField()])->where($metadata->getIdentifierField() . ' = ?', $entityData[$metadata->getIdentifierField()])->limit(1));
 }
示例#6
0
 /**
  * @param object $entity
  * @param string $identifier
  * @param array $arguments
  * @return object
  * @throws \Exception
  */
 public function execute($entity, $identifier, $arguments = [])
 {
     $entityType = $this->typeResolver->resolve($entity);
     $metadata = $this->metadataPool->getMetadata($entityType);
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $this->eventManager->dispatch('entity_manager_load_before', ['entity_type' => $entityType, 'identifier' => $identifier, 'arguments' => $arguments]);
     $this->eventManager->dispatchEntityEvent($entityType, 'load_before', ['identifier' => $identifier, 'arguments' => $arguments]);
     $entity = $this->readMain->execute($entity, $identifier);
     $entityData = array_merge($hydrator->extract($entity), $arguments);
     if (isset($entityData[$metadata->getLinkField()])) {
         $entity = $this->readAttributes->execute($entity, $arguments);
         $entity = $this->readExtensions->execute($entity, $arguments);
     }
     $this->eventManager->dispatchEntityEvent($entityType, 'load_after', ['entity' => $entity, 'arguments' => $arguments]);
     $this->eventManager->dispatch('entity_manager_load_after', ['entity_type' => $entityType, 'entity' => $entity, 'arguments' => $arguments]);
     return $entity;
 }
示例#7
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param array $arguments
  * @return object
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function execute($entityType, $entity, $arguments = [])
 {
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $this->deleteRow->execute($entityType, $hydrator->extract($entity));
     return $entity;
 }
 /**
  * @param string $entityType
  * @param object $entity
  * @throws \Exception
  * @return void
  */
 public function execute($entityType, $entity)
 {
     $metadata = $this->metadataPool->getMetadata($entityType);
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $this->objectRelationProcessor->validateDataIntegrity($metadata->getEntityTable(), $hydrator->extract($entity));
 }