Exemple #1
0
 /**
  * @param object $entity
  * @param string $identifier
  * @return object
  */
 public function execute($entity, $identifier)
 {
     $entityType = $this->typeResolver->resolve($entity);
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $entityData = $this->readRow->execute($entityType, $identifier);
     $entity = $hydrator->hydrate($entity, $entityData);
     return $entity;
 }
Exemple #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;
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 public function hydrate($entity, array $data)
 {
     $entityType = $this->typeResolver->resolve($entity);
     $mapper = $this->mapperPool->getMapper($entityType);
     $data = $mapper->databaseToEntity($entityType, array_merge($this->extract($entity), $data));
     $this->dataObjectHelper->populateWithArray($entity, $data, $entityType);
     return $entity;
 }
 /**
  * @param object $entity
  * @param array $arguments
  * @return object
  */
 public function execute($entity, $arguments = [])
 {
     $entityType = $this->typeResolver->resolve($entity);
     $actions = $this->extensionPool->getActions($entityType, 'delete');
     foreach ($actions as $action) {
         $action->execute($entity, $arguments);
     }
     return $entity;
 }
 /**
  * @param object $entity
  * @param array $arguments
  * @return object
  */
 public function execute($entity, $arguments = [])
 {
     $entityType = $this->typeResolver->resolve($entity);
     $hydrator = $this->hydratorPool->getHydrator($entityType);
     $entityData = array_merge($hydrator->extract($entity), $arguments);
     $actions = $this->attributePool->getActions($entityType, 'read');
     foreach ($actions as $action) {
         $entityData = array_merge($entityData, $action->execute($entityType, $entityData, $arguments));
     }
     $entity = $hydrator->hydrate($entity, $entityData);
     return $entity;
 }
 /**
  * @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));
 }
Exemple #7
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;
 }
Exemple #8
0
 /**
  * @param object $entity
  * @param array $arguments
  * @return object
  * @throws \Exception
  */
 public function execute($entity, $arguments = [])
 {
     $entityType = $this->typeResolver->resolve($entity);
     $metadata = $this->metadataPool->getMetadata($entityType);
     $connection = $this->resourceConnection->getConnectionByName($metadata->getEntityConnectionName());
     $this->transactionManager->start($connection);
     try {
         $this->eventManager->dispatch('entity_manager_delete_before', ['entity_type' => $entityType, 'entity' => $entity]);
         $this->eventManager->dispatchEntityEvent($entityType, 'delete_before', ['entity' => $entity]);
         $entity = $this->deleteExtensions->execute($entity, $arguments);
         $entity = $this->deleteAttributes->execute($entity, $arguments);
         $entity = $this->deleteMain->execute($entity, $arguments);
         $this->eventManager->dispatchEntityEvent($entityType, 'delete_after', ['entity' => $entity]);
         $this->eventManager->dispatch('entity_manager_delete_before', ['entity_type' => $entityType, 'entity' => $entity]);
         $this->transactionManager->commit();
     } catch (\Exception $e) {
         $this->transactionManager->rollBack();
         throw $e;
     }
     return $entity;
 }
 /**
  * @param object $dataObject
  * @param string $interfaceNames
  * @dataProvider resolveDataProvider
  */
 public function testResolve($dataObject, $interfaceName)
 {
     $customerDataObject = $this->objectManager->getObject($dataObject);
     $this->metadataPoolMock->expects($this->any())->method('hasConfiguration')->willReturnMap([[$interfaceName, true]]);
     $this->assertEquals($interfaceName, $this->resolver->resolve($customerDataObject));
 }