mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Refactored draft for Request Management
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Action;
|
||||
|
||||
use App\Entity\Attribut\ActionTypeAttribut;
|
||||
use App\DBAL\Types\ActionType;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
use App\Domain\RequestManagement\User\RequestedUser;
|
||||
use App\Domain\RequestManagement\Right\RequestedRightInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
* @todo Implement!
|
||||
*/
|
||||
class RequestedAction extends RequestedUser implements RequestedActionInterface
|
||||
{
|
||||
use ActionTypeAttribut{
|
||||
setActionType as setActionTypeTrait;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array Containes the mapping of non standard actions to a crud
|
||||
*/
|
||||
const ACTION_CRUD_MAP = [
|
||||
ActionType::LIST => CRUDType::READ,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var RequestedRightInterface
|
||||
*/
|
||||
private $requestedRight;
|
||||
|
||||
/**
|
||||
* @param RequestedRightInterface $requestedRight
|
||||
*/
|
||||
public function __construct(RequestedRightInterface $requestedRight)
|
||||
{
|
||||
$this->requestedRight = $requestedRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Entity\Attribut\ActionTypeAttributInterface::setActionType()
|
||||
*/
|
||||
public function setActionType(string $actionType): void
|
||||
{
|
||||
$this->setActionTypeTrait($actionType);
|
||||
$this->setRequestedRightCrudType($actionType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*/
|
||||
private function setRequestedRightCrudType(string $actionType): void
|
||||
{
|
||||
$crudType = $this->getCrudType($actionType);
|
||||
$this->requestedRight->setCrud($crudType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $actionType
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function getCrudType(string $actionType): string
|
||||
{
|
||||
if (key_exists($actionType, self::ACTION_CRUD_MAP)) {
|
||||
return self::ACTION_CRUD_MAP[$actionType];
|
||||
}
|
||||
|
||||
return $actionType;
|
||||
}
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Action;
|
||||
|
||||
use App\Entity\Attribut\ActionTypeAttributInterface;
|
||||
use App\Domain\RequestManagement\User\RequestedUserInterface;
|
||||
|
||||
/**
|
||||
* An action containes multiple attributes which are neccessary to process a request.
|
||||
*
|
||||
* @see ActionType
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedActionInterface extends ActionTypeAttributInterface, RequestedUserInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Action;
|
||||
|
||||
use App\Domain\RequestManagement\Right\RequestedRightServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RequestedActionService extends RequestedAction implements RequestedActionServiceInterface
|
||||
{
|
||||
/**
|
||||
* @param RequestedRightServiceInterface $requestedRightService
|
||||
*/
|
||||
public function __construct(RequestedRightServiceInterface $requestedRightService)
|
||||
{
|
||||
parent::__construct($requestedRightService);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Action;
|
||||
|
||||
/**
|
||||
* Allows to use a action as a service.
|
||||
* @todo Implement!
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedActionServiceInterface
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user