2019-01-20 12:54:56 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Domain\RequestManagement\Action;
|
|
|
|
|
2019-01-20 10:41:58 +01:00
|
|
|
use App\Attribut\ActionTypeAttribut;
|
2019-01-20 12:54:56 +01:00
|
|
|
use App\DBAL\Types\ActionType;
|
|
|
|
use App\DBAL\Types\Meta\Right\CRUDType;
|
|
|
|
use App\Domain\RequestManagement\User\RequestedUser;
|
2019-02-03 01:01:26 +01:00
|
|
|
use App\Domain\RequestManagement\User\RequestedUserInterface;
|
|
|
|
use App\Domain\UserManagement\UserSourceDirectorInterface;
|
2019-01-20 12:54:56 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
2019-01-20 13:33:33 +01:00
|
|
|
*
|
2019-01-20 12:54:56 +01:00
|
|
|
* @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 = [
|
2019-01-27 20:28:31 +01:00
|
|
|
ActionType::THREAD => CRUDType::READ,
|
2019-01-20 12:54:56 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
2019-02-03 01:01:26 +01:00
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
|
|
|
* @see \App\Domain\RequestManagement\User\RequestedUser::__construct()
|
2019-01-20 12:54:56 +01:00
|
|
|
*/
|
2019-02-03 01:01:26 +01:00
|
|
|
public function __construct(UserSourceDirectorInterface $userSourceDirector, RequestedUserInterface $requestedUser)
|
2019-01-20 12:54:56 +01:00
|
|
|
{
|
2019-02-03 01:01:26 +01:00
|
|
|
parent::__construct($userSourceDirector, $requestedUser);
|
2019-01-20 12:54:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritdoc}
|
|
|
|
*
|
2019-01-20 10:41:58 +01:00
|
|
|
* @see \App\Attribut\ActionTypeAttributInterface::setActionType()
|
2019-01-20 12:54:56 +01:00
|
|
|
*/
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|