mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +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
|
||||
{
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Entity;
|
||||
|
||||
use App\Entity\AbstractEntity;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Entity;
|
||||
|
||||
use App\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedEntityInterface extends EntityInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Entity;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RequestedEntityService extends RequestedEntity implements RequestedEntityServiceInterface
|
||||
{
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\Entity;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedEntityServiceInterface
|
||||
{
|
||||
}
|
12
application/symfony/src/Domain/RequestManagement/README.md
Normal file
12
application/symfony/src/Domain/RequestManagement/README.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Request Management
|
||||
The request management works with different layers.
|
||||
|
||||
### Layers
|
||||
Each layer contains out of __2 classes__ and __2 interfaces__ for it.
|
||||
One class contains the __logic__ and the other class contains the __service__. This makes the classes easier testable and mockable and follows the [SOLID Design Principles](https://en.wikipedia.org/wiki/SOLID). The layer order you can keep in mind with the acronym __RUAE__: __R__ight__U__ser__A__ction__E__ntity.
|
||||
|
||||
#### Right
|
||||
This is the basic request layer from which the other layers inhiere.
|
||||
#### User
|
||||
#### Action
|
||||
#### Entity
|
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
use App\Entity\Source\AbstractSource;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class RequestedSource extends AbstractSource implements RequestedSourceInterface
|
||||
{
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedSourceInterface extends SourceInterface
|
||||
{
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RequestedSourceService extends RequestedSource implements RequestedSourceServiceInterface
|
||||
{
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedSourceServiceInterface
|
||||
{
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
/**
|
||||
* Offers a Service for managing the rights.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedUserRightInterface extends RequestedRightInterface
|
||||
{
|
||||
}
|
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedUserRightServiceInterface extends RequestedUserRightInterface
|
||||
{
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
namespace App\Domain\RequestManagement\Right;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Entity\Attribut\CrudAttribut;
|
||||
@@ -9,6 +9,7 @@ use App\Entity\Attribut\RecieverAttribut;
|
||||
use App\Exception\PreconditionFailedException;
|
||||
use App\Exception\NotSetException;
|
||||
use App\Repository\Source\SourceRepositoryInterface;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -30,7 +31,7 @@ class RequestedRight implements RequestedRightInterface
|
||||
private $source;
|
||||
|
||||
/**
|
||||
* @var RequestedSourceInterface
|
||||
* @var RequestedEntityInterface
|
||||
*/
|
||||
private $requestedSource;
|
||||
|
||||
@@ -50,7 +51,7 @@ class RequestedRight implements RequestedRightInterface
|
||||
/**
|
||||
* @throws PreconditionFailedException If the source has no id or slug
|
||||
*/
|
||||
private function validateRequestedSource(): void
|
||||
private function validateRequestedEntity(): void
|
||||
{
|
||||
if ($this->requestedSource->hasSlug() || $this->requestedSource->hasId()) {
|
||||
return;
|
||||
@@ -63,11 +64,11 @@ class RequestedRight implements RequestedRightInterface
|
||||
*
|
||||
* @see https://en.wikipedia.org/wiki/Lazy_loading
|
||||
* {@inheritdoc}
|
||||
* @see \App\Domain\RequestManagement\RequestedRightInterface::getSource()
|
||||
* @see \App\Domain\RequestManagement\Right\RequestedRightInterface::getSource()
|
||||
*/
|
||||
final public function getSource(): SourceInterface
|
||||
{
|
||||
$this->validateRequestedSource();
|
||||
$this->validateRequestedEntity();
|
||||
$this->loadSource();
|
||||
$this->validateLoad();
|
||||
|
||||
@@ -85,9 +86,9 @@ class RequestedRight implements RequestedRightInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\RequestManagement\RequestedRightInterface::setRequestedSource()
|
||||
* @see \App\Domain\RequestManagement\Right\RequestedRightInterface::setRequestedEntity()
|
||||
*/
|
||||
final public function setRequestedSource(RequestedSourceInterface $requestedSource)
|
||||
final public function setRequestedEntity(RequestedEntityInterface $requestedSource)
|
||||
{
|
||||
$this->requestedSource = $requestedSource;
|
||||
}
|
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
namespace App\Domain\RequestManagement\Right;
|
||||
|
||||
use App\Entity\Attribut\CrudAttributInterface;
|
||||
use App\Entity\Attribut\RecieverAttributInterface;
|
||||
use App\Entity\Attribut\LayerAttributInterface;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -13,9 +14,9 @@ use App\Entity\Source\SourceInterface;
|
||||
interface RequestedRightInterface extends CrudAttributInterface, RecieverAttributInterface, LayerAttributInterface
|
||||
{
|
||||
/**
|
||||
* @param RequestedSourceInterface $requestedSource
|
||||
* @param RequestedEntityInterface $requestedSource
|
||||
*/
|
||||
public function setRequestedSource(RequestedSourceInterface $requestedSource);
|
||||
public function setRequestedEntity(RequestedEntityInterface $requestedSource);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
namespace App\Domain\RequestManagement\Right;
|
||||
|
||||
/**
|
||||
* Allows to use a right as a Service.
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
namespace App\Domain\RequestManagement\Right;
|
||||
|
||||
/**
|
||||
* Allows to use a right as a Service.
|
@@ -1,15 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
namespace App\Domain\RequestManagement\User;
|
||||
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\UserManagement\UserSourceDirectorInterface;
|
||||
use App\Exception\SetNotPossibleException;
|
||||
use App\Domain\RequestManagement\Right\RequestedRightInterface;
|
||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class RequestedUserRight implements RequestedUserRightInterface
|
||||
class RequestedUser implements RequestedUserInterface
|
||||
{
|
||||
/**
|
||||
* @var UserSourceDirectorInterface
|
||||
@@ -101,12 +103,10 @@ class RequestedUserRight implements RequestedUserRightInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \App\Domain\RequestManagement\RequestedRightInterface::setRequestedSource()
|
||||
* @param RequestedEntityInterface $requestedSource
|
||||
*/
|
||||
public function setRequestedSource(RequestedSourceInterface $requestedSource)
|
||||
public function setRequestedEntity(RequestedEntityInterface $requestedSource)
|
||||
{
|
||||
$this->requestedRight->setRequestedSource($requestedSource);
|
||||
$this->requestedRight->setRequestedEntity($requestedSource);
|
||||
}
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\User;
|
||||
|
||||
use App\Domain\RequestManagement\Right\RequestedRightInterface;
|
||||
|
||||
/**
|
||||
* Offers a Service for managing the rights.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedUserInterface extends RequestedRightInterface
|
||||
{
|
||||
}
|
@@ -1,13 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement;
|
||||
namespace App\Domain\RequestManagement\User;
|
||||
|
||||
use App\Domain\UserManagement\UserSourceDirectorServiceInterface;
|
||||
use App\Domain\RequestManagement\Right\RequestedRightServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class RequestedUserRightService extends RequestedUserRight implements RequestedUserRightServiceInterface
|
||||
final class RequestedUserService extends RequestedUser implements RequestedUserServiceInterface
|
||||
{
|
||||
/**
|
||||
* @param UserSourceDirectorServiceInterface $userSourceDirectorService
|
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domain\RequestManagement\User;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface RequestedUserServiceInterface extends RequestedUserInterface
|
||||
{
|
||||
}
|
Reference in New Issue
Block a user