/** * @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) ); }
/** * @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; }
/** * @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; }
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')); }