mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Declared setActionType as immutable for RequestedRight
This commit is contained in:
parent
9d63f34a7b
commit
776a7fe282
@ -31,12 +31,13 @@ final class LayerController extends AbstractAPIController
|
||||
* ".{_format}",
|
||||
* methods={"GET","POST"}
|
||||
* )
|
||||
*
|
||||
* @todo Mayber create an own controller for sources, because they have some special logic!
|
||||
*/
|
||||
public function create(Request $request,MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService, string $layer): Response
|
||||
public function create(Request $request, MVCRoutineServiceInterface $mvcRoutineService, RequestedActionServiceInterface $requestedActionService, string $layer): Response
|
||||
{
|
||||
//Not implemented yet in MVC routine. This is just a draft!
|
||||
if($request->query->has(ClassAttributInterface::CLASS_ATTRIBUT_NAME)){
|
||||
if ($request->query->has(ClassAttributInterface::CLASS_ATTRIBUT_NAME)) {
|
||||
$class = $request->query->get(ClassAttributInterface::CLASS_ATTRIBUT_NAME);
|
||||
$requestedActionService->getRequestedEntity()->setClass($class);
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ use Infinito\Entity\Meta\MetaInterface;
|
||||
use Infinito\Exception\NotCorrectInstanceException;
|
||||
use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
|
||||
use Infinito\Attribut\ActionTypeAttribut;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -20,7 +21,9 @@ use Infinito\Attribut\ActionTypeAttribut;
|
||||
*/
|
||||
class RequestedRight implements RequestedRightInterface
|
||||
{
|
||||
use ActionTypeAttribut, LayerAttribut, RecieverAttribut, RequestedEntityAttribut;
|
||||
use LayerAttribut, RecieverAttribut, RequestedEntityAttribut, ActionTypeAttribut{
|
||||
setActionType as private setActionTypeTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var SourceInterface
|
||||
@ -67,6 +70,20 @@ class RequestedRight implements RequestedRightInterface
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function declares the attribute actionType as inmutable
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Attribut\ActionTypeAttributInterface::setActionType()
|
||||
*/
|
||||
public function setActionType(string $actionType): void
|
||||
{
|
||||
if (isset($this->actionType)) {
|
||||
throw new AllreadySetException("The action type is allready set! Origine: $this->actionType New: $actionType");
|
||||
}
|
||||
$this->setActionTypeTrait($actionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses some kind of Lazy loading.
|
||||
*
|
||||
|
@ -16,6 +16,8 @@ use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Infinito\Entity\Meta\Law;
|
||||
use Infinito\Entity\Source\SourceInterface;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\AllreadySetException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -105,4 +107,13 @@ class RequestedRightTest extends KernelTestCase
|
||||
$responseSource1 = $this->requestedRight->getSource();
|
||||
$this->assertEquals($responseSource1, $source);
|
||||
}
|
||||
|
||||
public function testSetActionType(): void
|
||||
{
|
||||
$attributType = ActionType::CREATE;
|
||||
$this->requestedRight->setActionType($attributType);
|
||||
$this->assertEquals($attributType, $this->requestedRight->getActionType());
|
||||
$this->expectException(AllreadySetException::class);
|
||||
$this->requestedRight->setActionType($attributType);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user