Refactored ActionManagement

This commit is contained in:
Kevin Frantz 2019-04-14 14:12:09 +02:00
parent 77896004b6
commit 131d6aa157
14 changed files with 1692 additions and 46 deletions

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 187 KiB

View File

@ -11,14 +11,14 @@ namespace Infinito\Domain\ActionManagement;
abstract class AbstractActionConstructor abstract class AbstractActionConstructor
{ {
/** /**
* @var ActionServiceInterface * @var ActionDAOServiceInterface
*/ */
protected $actionService; protected $actionService;
/** /**
* @param ActionServiceInterface $actionService * @param ActionDAOServiceInterface $actionService
*/ */
final public function __construct(ActionServiceInterface $actionService) final public function __construct(ActionDAOServiceInterface $actionService)
{ {
$this->actionService = $actionService; $this->actionService = $actionService;
} }

View File

@ -16,10 +16,10 @@ use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface
/** /**
* @author kevinfrantz * @author kevinfrantz
*/ */
final class ActionService implements ActionServiceInterface final class ActionDAOService implements ActionDAOServiceInterface
{ {
/** /**
* @var Request * @var RequestStack
*/ */
private $requestStack; private $requestStack;
@ -64,7 +64,7 @@ final class ActionService implements ActionServiceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getRequestedAction() * @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getRequestedAction()
*/ */
public function getRequestedAction(): RequestedActionInterface public function getRequestedAction(): RequestedActionInterface
{ {
@ -74,7 +74,7 @@ final class ActionService implements ActionServiceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::isRequestedActionSecure() * @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::isRequestedActionSecure()
*/ */
public function isRequestedActionSecure(): bool public function isRequestedActionSecure(): bool
{ {
@ -92,7 +92,7 @@ final class ActionService implements ActionServiceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getRequest() * @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getRequest()
*/ */
public function getRequest(): Request public function getRequest(): Request
{ {
@ -100,9 +100,9 @@ final class ActionService implements ActionServiceInterface
} }
/** /**
* {@use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;inheritDoc}. * {@inheritdoc}
* *
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getRepository() * @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getRepository()
*/ */
public function getRepository(): RepositoryInterface public function getRepository(): RepositoryInterface
{ {
@ -114,7 +114,7 @@ final class ActionService implements ActionServiceInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getEntityManager() * @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getEntityManager()
*/ */
public function getEntityManager(): EntityManagerInterface public function getEntityManager(): EntityManagerInterface
{ {

View File

@ -13,7 +13,7 @@ use Doctrine\ORM\EntityManagerInterface;
* *
* @author kevinfrantz * @author kevinfrantz
*/ */
interface ActionServiceInterface interface ActionDAOServiceInterface
{ {
/** /**
* @return RequestedActionInterface Returns the requested action * @return RequestedActionInterface Returns the requested action

View File

@ -0,0 +1,3 @@
# ActionManagement
## Brainstorming
![Brainstorming Class UML Diagram](.meta/uml-class-brainstorming.svg)

View File

@ -43,10 +43,13 @@ final class ProcessService implements ProcessServiceInterface
/** /**
* @return bool True if the the entity exist * @return bool True if the the entity exist
*/ */
private function doesEntityExist():bool{ private function doesEntityExist(): bool
{
$requestedAction = $this->requestedActionService; $requestedAction = $this->requestedActionService;
return $requestedAction->hasRequestedEntity() && $requestedAction->getRequestedEntity()->hasIdentity(); return $requestedAction->hasRequestedEntity() && $requestedAction->getRequestedEntity()->hasIdentity();
} }
/** /**
* @return mixed|null * @return mixed|null
* *
@ -63,10 +66,10 @@ final class ProcessService implements ProcessServiceInterface
} }
// CREATE // CREATE
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class); $this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
return; return;
} }
/** /**
* @param ActionHandlerServiceInterface $actionHandlerService * @param ActionHandlerServiceInterface $actionHandlerService
* @param ActionsResultsDAOServiceInterface $actionTemplateDataStore * @param ActionsResultsDAOServiceInterface $actionTemplateDataStore

View File

@ -3,7 +3,6 @@
namespace Infinito\Domain\ViewManagement; namespace Infinito\Domain\ViewManagement;
use FOS\RestBundle\View\View; use FOS\RestBundle\View\View;
use Infinito\Domain\ActionManagement\ActionServiceInterface;
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface; use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface; use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface; use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface;
@ -19,23 +18,18 @@ final class ViewBuilder implements ViewBuilderInterface
/** /**
* @var string The path to the atom entity template * @var string The path to the atom entity template
*/ */
const TWIG_ENTITY_ATOM_TEMPLATE_PATH = 'entity/_entity.html.twig'; private const TWIG_ENTITY_ATOM_TEMPLATE_PATH = 'entity/_entity.html.twig';
/** /**
* @var string The path to the molecule entity template * @var string The path to the molecule entity template
*/ */
const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig'; private const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig';
/** /**
* @var View * @var View
*/ */
private $view; private $view;
/**
* @var ActionServiceInterface
*/
private $actionService;
/** /**
* @var ActionFactoryServiceInterface * @var ActionFactoryServiceInterface
*/ */
@ -90,15 +84,13 @@ final class ViewBuilder implements ViewBuilderInterface
} }
/** /**
* @param ActionServiceInterface $actionService
* @param ActionFactoryServiceInterface $actionFactoryService * @param ActionFactoryServiceInterface $actionFactoryService
* @param TemplateNameServiceInterface $templateNameService * @param TemplateNameServiceInterface $templateNameService
* @param ValidGetParameterServiceInterface $validGetParameterService * @param ValidGetParameterServiceInterface $validGetParameterService
*/ */
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, ValidGetParameterServiceInterface $validGetParameterService) public function __construct(ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, ValidGetParameterServiceInterface $validGetParameterService)
{ {
$this->view = View::create(); $this->view = View::create();
$this->actionService = $actionService;
$this->templateNameService = $templateNameService; $this->templateNameService = $templateNameService;
$this->validGetParameterService = $validGetParameterService; $this->validGetParameterService = $validGetParameterService;
} }

View File

@ -3,7 +3,7 @@
namespace tests\Integration\Domain\ActionManagement; namespace tests\Integration\Domain\ActionManagement;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
/** /**
@ -12,7 +12,7 @@ use Doctrine\ORM\EntityManagerInterface;
class ActionServiceIntegrationTest extends KernelTestCase class ActionServiceIntegrationTest extends KernelTestCase
{ {
/** /**
* @var ActionServiceInterface * @var ActionDAOServiceInterface
*/ */
private $actionService; private $actionService;
@ -24,10 +24,10 @@ class ActionServiceIntegrationTest extends KernelTestCase
public function setUp(): void public function setUp(): void
{ {
self::bootKernel(); self::bootKernel();
$this->actionService = self::$container->get(ActionServiceInterface::class); $this->actionService = self::$container->get(ActionDAOServiceInterface::class);
} }
public function testEnityManager(): void public function testEntityManager(): void
{ {
$this->assertInstanceOf(EntityManagerInterface::class, $this->actionService->getEntityManager()); $this->assertInstanceOf(EntityManagerInterface::class, $this->actionService->getEntityManager());
} }

View File

@ -3,9 +3,9 @@
namespace Tests\Integration\Domain\ActionManagement\Create; namespace Tests\Integration\Domain\ActionManagement\Create;
use Infinito\Domain\ActionManagement\Create\CreateSourceAction; use Infinito\Domain\ActionManagement\Create\CreateSourceAction;
use Infinito\Domain\ActionManagement\ActionService; use Infinito\Domain\ActionManagement\ActionDAOService;
use Infinito\Domain\ActionManagement\Create\CreateActionInterface; use Infinito\Domain\ActionManagement\Create\CreateActionInterface;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Infinito\Entity\Source\PureSourceInterface; use Infinito\Entity\Source\PureSourceInterface;
use Infinito\Domain\RequestManagement\Action\RequestedActionService; use Infinito\Domain\RequestManagement\Action\RequestedActionService;
@ -39,7 +39,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
private $createSourceAction; private $createSourceAction;
/** /**
* @var ActionServiceInterface * @var ActionDAOServiceInterface
*/ */
private $actionService; private $actionService;
@ -80,7 +80,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
$layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager); $layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
$rightTransformerService = new RightTransformerService(); $rightTransformerService = new RightTransformerService();
$secureRequestedRightChecker = new SecureRequestedRightCheckerService($rightTransformerService); $secureRequestedRightChecker = new SecureRequestedRightCheckerService($rightTransformerService);
$this->actionService = new ActionService($this->requestedActionService, $secureRequestedRightChecker, $this->requestStack, $layerRepositoryFactoryService, $entityFormBuilderService, $entityManager); $this->actionService = new ActionDAOService($this->requestedActionService, $secureRequestedRightChecker, $this->requestStack, $layerRepositoryFactoryService, $entityFormBuilderService, $entityManager);
$this->createSourceAction = new CreateSourceAction($this->actionService); $this->createSourceAction = new CreateSourceAction($this->actionService);
} }

View File

@ -4,7 +4,7 @@ namespace tests\Unit\Domain\ActionManagement;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Domain\ActionManagement\ActionFactoryService; use Infinito\Domain\ActionManagement\ActionFactoryService;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
use Infinito\Domain\ActionManagement\ActionInterface; use Infinito\Domain\ActionManagement\ActionInterface;
use Infinito\Domain\RequestManagement\Action\RequestedAction; use Infinito\Domain\RequestManagement\Action\RequestedAction;
use Infinito\Domain\RequestManagement\Right\RequestedRight; use Infinito\Domain\RequestManagement\Right\RequestedRight;
@ -25,7 +25,7 @@ class ActionFactoryServiceTest extends TestCase
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class); $userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedUser = new RequestedUser($userSourceDirector, $requestedRight); $requestedUser = new RequestedUser($userSourceDirector, $requestedRight);
$requestedAction = new RequestedAction($requestedUser); $requestedAction = new RequestedAction($requestedUser);
$actionService = $this->createMock(ActionServiceInterface::class); $actionService = $this->createMock(ActionDAOServiceInterface::class);
$actionService->method('getRequestedAction')->willReturn($requestedAction); $actionService->method('getRequestedAction')->willReturn($requestedAction);
$actionFactoryService = new ActionFactoryService($actionService); $actionFactoryService = new ActionFactoryService($actionService);
$requestedAction->setLayer($layer); $requestedAction->setLayer($layer);

View File

@ -3,12 +3,12 @@
namespace tests\Unit\Domain\ActionManagement; namespace tests\Unit\Domain\ActionManagement;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Domain\ActionManagement\ActionService; use Infinito\Domain\ActionManagement\ActionDAOService;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface; use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface; use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
use Infinito\Repository\RepositoryInterface; use Infinito\Repository\RepositoryInterface;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface; use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
@ -50,7 +50,7 @@ class ActionServiceTest extends TestCase
private $layerRepositoryFactoryService; private $layerRepositoryFactoryService;
/** /**
* @var ActionServiceInterface * @var ActionDAOServiceInterface
*/ */
private $actionService; private $actionService;
@ -84,7 +84,7 @@ class ActionServiceTest extends TestCase
$this->requestStack = $this->createMock(RequestStack::class); $this->requestStack = $this->createMock(RequestStack::class);
$this->layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class); $this->layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$this->entityManager = $this->createMock(EntityManagerInterface::class); $this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->actionService = new ActionService($this->requestedActionService, $this->secureRequestedRightCheckerService, $this->requestStack, $this->layerRepositoryFactoryService, $this->requestedActionFormBuilderService, $this->entityManager); $this->actionService = new ActionDAOService($this->requestedActionService, $this->secureRequestedRightCheckerService, $this->requestStack, $this->layerRepositoryFactoryService, $this->requestedActionFormBuilderService, $this->entityManager);
} }
public function testIsRequestedActionSecure(): void public function testIsRequestedActionSecure(): void

View File

@ -5,7 +5,7 @@ namespace tests\Unit\Domain\ActionManagement\Read;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Domain\ActionManagement\ActionInterface; use Infinito\Domain\ActionManagement\ActionInterface;
use Infinito\Domain\ActionManagement\AbstractAction; use Infinito\Domain\ActionManagement\AbstractAction;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Infinito\Exception\NotValidByFormException; use Infinito\Exception\NotValidByFormException;
@ -20,13 +20,13 @@ class AbstractActionTest extends TestCase
private $action; private $action;
/** /**
* @var ActionServiceInterface|MockObject * @var ActionDAOServiceInterface|MockObject
*/ */
private $actionService; private $actionService;
public function setUp(): void public function setUp(): void
{ {
$this->actionService = $this->createMock(ActionServiceInterface::class); $this->actionService = $this->createMock(ActionDAOServiceInterface::class);
$this->action = new class($this->actionService) extends AbstractAction { $this->action = new class($this->actionService) extends AbstractAction {
public $isSecure; public $isSecure;
public $validByForm; public $validByForm;

View File

@ -5,7 +5,7 @@ namespace tests\Unit\Domain\SecureCRUDManagement\CRUD\Read;
use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\EntityManagerInterface;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Domain\ActionManagement\Read\ReadAction; use Infinito\Domain\ActionManagement\Read\ReadAction;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
use Infinito\Domain\ActionManagement\Read\ReadActionInterface; use Infinito\Domain\ActionManagement\Read\ReadActionInterface;
use Infinito\Exception\NotSecureException; use Infinito\Exception\NotSecureException;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface; use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
@ -23,7 +23,7 @@ class ReadSourceActionTest extends TestCase
private $entityManager; private $entityManager;
/** /**
* @var ActionServiceInterface * @var ActionDAOServiceInterface
*/ */
private $actionService; private $actionService;
@ -50,7 +50,7 @@ class ReadSourceActionTest extends TestCase
$this->entityManager = $this->createMock(EntityManagerInterface::class); $this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->requestedAction = $this->createMock(RequestedActionInterface::class); $this->requestedAction = $this->createMock(RequestedActionInterface::class);
$this->requestedAction->method('getRequestedEntity')->willReturn($this->requestedEntity); $this->requestedAction->method('getRequestedEntity')->willReturn($this->requestedEntity);
$this->actionService = $this->createMock(ActionServiceInterface::class); $this->actionService = $this->createMock(ActionDAOServiceInterface::class);
$this->actionService->method('getEntityManager')->willReturn($this->entityManager); $this->actionService->method('getEntityManager')->willReturn($this->entityManager);
$this->actionService->method('getRequestedAction')->willReturn($this->requestedAction); $this->actionService->method('getRequestedAction')->willReturn($this->requestedAction);
$this->sourceReadAction = new ReadAction($this->actionService); $this->sourceReadAction = new ReadAction($this->actionService);