/**
  * @dataProvider executeDataProvider
  *
  * @param array $expected
  * @param string $entityType
  * @param string $actionName
  * @return void
  */
 public function testExecute(array $expected, $entityType, $actionName)
 {
     $this->assertEquals(
         $expected,
         $this->subject->getActions($entityType, $actionName)
     );
 }
Esempio n. 2
0
 /**
  * @param string $entityType
  * @param object $entity
  * @param array $data
  * @return object
  * @throws \Exception
  */
 public function execute($entityType, $entity, $data = [])
 {
     $hydrator = $this->metadataPool->getHydrator($entityType);
     $entityData = array_merge($hydrator->extract($entity), $data);
     $actions = $this->extensionPool->getActions($entityType, 'create');
     foreach ($actions as $action) {
         $entityData = $action->execute($entityType, $entityData);
     }
     $entity = $hydrator->hydrate($entity, $entityData);
     return $entity;
 }
Esempio n. 3
0
 /**
  * @param string $entityType
  * @param object $entity
  * @return object
  * @throws \Exception
  */
 public function execute($entityType, $entity)
 {
     $hydrator = $this->metadataPool->getHydrator($entityType);
     $entityData = $hydrator->extract($entity);
     $actions = $this->extensionPool->getActions($entityType, 'read');
     foreach ($actions as $action) {
         $data = $action->execute($entityType, $entityData);
         $entity = $hydrator->hydrate($entity, $data);
     }
     return $entity;
 }
Esempio n. 4
0
 public function testExecute()
 {
     $this->assertEquals(['test_extension_1' => 'Test\\Extension1\\Entity\\ReadHandler', 'test_extension_2' => 'Test\\Extension2\\Default\\CreateHandler'], $this->subject->getActions('Test\\First\\Entity', 'read'));
 }