mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Refactored ActionManagement
This commit is contained in:
parent
77896004b6
commit
131d6aa157
Binary file not shown.
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 187 KiB |
@ -11,14 +11,14 @@ namespace Infinito\Domain\ActionManagement;
|
||||
abstract class AbstractActionConstructor
|
||||
{
|
||||
/**
|
||||
* @var ActionServiceInterface
|
||||
* @var ActionDAOServiceInterface
|
||||
*/
|
||||
protected $actionService;
|
||||
|
||||
/**
|
||||
* @param ActionServiceInterface $actionService
|
||||
* @param ActionDAOServiceInterface $actionService
|
||||
*/
|
||||
final public function __construct(ActionServiceInterface $actionService)
|
||||
final public function __construct(ActionDAOServiceInterface $actionService)
|
||||
{
|
||||
$this->actionService = $actionService;
|
||||
}
|
||||
|
@ -16,10 +16,10 @@ use Infinito\Domain\SecureManagement\SecureRequestedRightCheckerServiceInterface
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ActionService implements ActionServiceInterface
|
||||
final class ActionDAOService implements ActionDAOServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var Request
|
||||
* @var RequestStack
|
||||
*/
|
||||
private $requestStack;
|
||||
|
||||
@ -64,7 +64,7 @@ final class ActionService implements ActionServiceInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getRequestedAction()
|
||||
* @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getRequestedAction()
|
||||
*/
|
||||
public function getRequestedAction(): RequestedActionInterface
|
||||
{
|
||||
@ -74,7 +74,7 @@ final class ActionService implements ActionServiceInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::isRequestedActionSecure()
|
||||
* @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::isRequestedActionSecure()
|
||||
*/
|
||||
public function isRequestedActionSecure(): bool
|
||||
{
|
||||
@ -92,7 +92,7 @@ final class ActionService implements ActionServiceInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getRequest()
|
||||
* @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getRequest()
|
||||
*/
|
||||
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
|
||||
{
|
||||
@ -114,7 +114,7 @@ final class ActionService implements ActionServiceInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\ActionManagement\ActionServiceInterface::getEntityManager()
|
||||
* @see \Infinito\Domain\ActionManagement\ActionDAOServiceInterface::getEntityManager()
|
||||
*/
|
||||
public function getEntityManager(): EntityManagerInterface
|
||||
{
|
@ -13,7 +13,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ActionServiceInterface
|
||||
interface ActionDAOServiceInterface
|
||||
{
|
||||
/**
|
||||
* @return RequestedActionInterface Returns the requested action
|
@ -0,0 +1,3 @@
|
||||
# ActionManagement
|
||||
## Brainstorming
|
||||
![Brainstorming Class UML Diagram](.meta/uml-class-brainstorming.svg)
|
@ -43,10 +43,13 @@ final class ProcessService implements ProcessServiceInterface
|
||||
/**
|
||||
* @return bool True if the the entity exist
|
||||
*/
|
||||
private function doesEntityExist():bool{
|
||||
private function doesEntityExist(): bool
|
||||
{
|
||||
$requestedAction = $this->requestedActionService;
|
||||
|
||||
return $requestedAction->hasRequestedEntity() && $requestedAction->getRequestedEntity()->hasIdentity();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed|null
|
||||
*
|
||||
@ -63,10 +66,10 @@ final class ProcessService implements ProcessServiceInterface
|
||||
}
|
||||
// CREATE
|
||||
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param ActionHandlerServiceInterface $actionHandlerService
|
||||
* @param ActionsResultsDAOServiceInterface $actionTemplateDataStore
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace Infinito\Domain\ViewManagement;
|
||||
|
||||
use FOS\RestBundle\View\View;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
|
||||
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
|
||||
use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface;
|
||||
@ -19,23 +18,18 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig';
|
||||
private const TWIG_ENTITY_MOLECULE_TEMPLATE_PATH = 'entity/entity.html.twig';
|
||||
|
||||
/**
|
||||
* @var View
|
||||
*/
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var ActionServiceInterface
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
/**
|
||||
* @var ActionFactoryServiceInterface
|
||||
*/
|
||||
@ -90,15 +84,13 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ActionServiceInterface $actionService
|
||||
* @param ActionFactoryServiceInterface $actionFactoryService
|
||||
* @param TemplateNameServiceInterface $templateNameService
|
||||
* @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->actionService = $actionService;
|
||||
$this->templateNameService = $templateNameService;
|
||||
$this->validGetParameterService = $validGetParameterService;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace tests\Integration\Domain\ActionManagement;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
@ -12,7 +12,7 @@ use Doctrine\ORM\EntityManagerInterface;
|
||||
class ActionServiceIntegrationTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var ActionServiceInterface
|
||||
* @var ActionDAOServiceInterface
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
@ -24,10 +24,10 @@ class ActionServiceIntegrationTest extends KernelTestCase
|
||||
public function setUp(): void
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace Tests\Integration\Domain\ActionManagement\Create;
|
||||
|
||||
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\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Infinito\Entity\Source\PureSourceInterface;
|
||||
use Infinito\Domain\RequestManagement\Action\RequestedActionService;
|
||||
@ -39,7 +39,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
|
||||
private $createSourceAction;
|
||||
|
||||
/**
|
||||
* @var ActionServiceInterface
|
||||
* @var ActionDAOServiceInterface
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
@ -80,7 +80,7 @@ class CreateSourceActionIntegrationTest extends KernelTestCase
|
||||
$layerRepositoryFactoryService = new LayerRepositoryFactoryService($entityManager);
|
||||
$rightTransformerService = new 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);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace tests\Unit\Domain\ActionManagement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\ActionManagement\ActionFactoryService;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionInterface;
|
||||
use Infinito\Domain\RequestManagement\Action\RequestedAction;
|
||||
use Infinito\Domain\RequestManagement\Right\RequestedRight;
|
||||
@ -25,7 +25,7 @@ class ActionFactoryServiceTest extends TestCase
|
||||
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
|
||||
$requestedUser = new RequestedUser($userSourceDirector, $requestedRight);
|
||||
$requestedAction = new RequestedAction($requestedUser);
|
||||
$actionService = $this->createMock(ActionServiceInterface::class);
|
||||
$actionService = $this->createMock(ActionDAOServiceInterface::class);
|
||||
$actionService->method('getRequestedAction')->willReturn($requestedAction);
|
||||
$actionFactoryService = new ActionFactoryService($actionService);
|
||||
$requestedAction->setLayer($layer);
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace tests\Unit\Domain\ActionManagement;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\ActionManagement\ActionService;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOService;
|
||||
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
||||
use Infinito\Repository\RepositoryInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
@ -50,7 +50,7 @@ class ActionServiceTest extends TestCase
|
||||
private $layerRepositoryFactoryService;
|
||||
|
||||
/**
|
||||
* @var ActionServiceInterface
|
||||
* @var ActionDAOServiceInterface
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
@ -84,7 +84,7 @@ class ActionServiceTest extends TestCase
|
||||
$this->requestStack = $this->createMock(RequestStack::class);
|
||||
$this->layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::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
|
||||
|
@ -5,7 +5,7 @@ namespace tests\Unit\Domain\ActionManagement\Read;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\ActionManagement\ActionInterface;
|
||||
use Infinito\Domain\ActionManagement\AbstractAction;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Infinito\Exception\NotValidByFormException;
|
||||
|
||||
@ -20,13 +20,13 @@ class AbstractActionTest extends TestCase
|
||||
private $action;
|
||||
|
||||
/**
|
||||
* @var ActionServiceInterface|MockObject
|
||||
* @var ActionDAOServiceInterface|MockObject
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->actionService = $this->createMock(ActionServiceInterface::class);
|
||||
$this->actionService = $this->createMock(ActionDAOServiceInterface::class);
|
||||
$this->action = new class($this->actionService) extends AbstractAction {
|
||||
public $isSecure;
|
||||
public $validByForm;
|
||||
|
@ -5,7 +5,7 @@ namespace tests\Unit\Domain\SecureCRUDManagement\CRUD\Read;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Infinito\Domain\ActionManagement\Read\ReadAction;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionDAOServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\Read\ReadActionInterface;
|
||||
use Infinito\Exception\NotSecureException;
|
||||
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
@ -23,7 +23,7 @@ class ReadSourceActionTest extends TestCase
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var ActionServiceInterface
|
||||
* @var ActionDAOServiceInterface
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
@ -50,7 +50,7 @@ class ReadSourceActionTest extends TestCase
|
||||
$this->entityManager = $this->createMock(EntityManagerInterface::class);
|
||||
$this->requestedAction = $this->createMock(RequestedActionInterface::class);
|
||||
$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('getRequestedAction')->willReturn($this->requestedAction);
|
||||
$this->sourceReadAction = new ReadAction($this->actionService);
|
||||
|
Loading…
Reference in New Issue
Block a user