mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Refactored draft for Request Management
This commit is contained in:
		@@ -0,0 +1,36 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\CRUDManagement;
 | 
			
		||||
 | 
			
		||||
use App\Entity\EntityInterface;
 | 
			
		||||
use App\Repository\RepositoryInterface;
 | 
			
		||||
use Doctrine\ORM\EntityManagerInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
final class RepositoryFactoryService implements RepositoryFactoryServiceInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var EntityManagerInterface
 | 
			
		||||
     */
 | 
			
		||||
    private $entityManager;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param EntityManagerInterface $entityManager
 | 
			
		||||
     */
 | 
			
		||||
    private function __construct(EntityManagerInterface $entityManager)
 | 
			
		||||
    {
 | 
			
		||||
        $this->entityManager = $entityManager;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Domain\CRUDManagement\RepositoryFactoryInterface::getRepository()
 | 
			
		||||
     */
 | 
			
		||||
    public function getRepository(EntityInterface $entity): RepositoryInterface
 | 
			
		||||
    {
 | 
			
		||||
        $this->entityManager->getRepository(get_class($entity));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,21 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\CRUDManagement;
 | 
			
		||||
 | 
			
		||||
use App\Repository\RepositoryInterface;
 | 
			
		||||
use App\Entity\EntityInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Offers a fabric for entity repositories.
 | 
			
		||||
 *
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface RepositoryFactoryServiceInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param EntityInterface $entity
 | 
			
		||||
     *
 | 
			
		||||
     * @return RepositoryInterface The repositoy of the interface
 | 
			
		||||
     */
 | 
			
		||||
    public function getRepository(EntityInterface $entity): RepositoryInterface;
 | 
			
		||||
}
 | 
			
		||||
@@ -9,6 +9,9 @@ A folder MUST end on the suffix ** *Management ** to show that it has the purpos
 | 
			
		||||
 | 
			
		||||
# Domain Overview
 | 
			
		||||
 | 
			
		||||
## CRUD Management
 | 
			
		||||
### Repository Factory Service
 | 
			
		||||
Offers a fabric for entity repositories.
 | 
			
		||||
## Entity Management
 | 
			
		||||
### Entity Meta Information ###
 | 
			
		||||
Offers some meta information about an entity
 | 
			
		||||
@@ -31,18 +34,7 @@ Maps a path to a namespace.
 | 
			
		||||
 | 
			
		||||
## Request Management
 | 
			
		||||
 | 
			
		||||
Offers classes to manage requests for rights, users and sources.
 | 
			
		||||
 | 
			
		||||
### Logic
 | 
			
		||||
- Requested Right
 | 
			
		||||
- Requested Source
 | 
			
		||||
- Requested User
 | 
			
		||||
 | 
			
		||||
### Services
 | 
			
		||||
- Requested Right Service
 | 
			
		||||
- Requested Source Service
 | 
			
		||||
- Requested User Service
 | 
			
		||||
 | 
			
		||||
Offers classes to manage requests for rights, users and sources. A [detailed description](./RequestManagement/README.md) is available.
 | 
			
		||||
## Right Management
 | 
			
		||||
### Right Checker ###
 | 
			
		||||
Checks if the crud, layer and source combination is granted by a right.
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,43 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ViewManagement;
 | 
			
		||||
 | 
			
		||||
use FOS\RestBundle\View\View;
 | 
			
		||||
use App\Domain\RequestManagement\RequestedUser;
 | 
			
		||||
use App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryService;
 | 
			
		||||
use App\Domain\SecureCRUDManagement\Factory\SecureCRUDFactoryServiceInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
class AbstractViewBuilder implements ViewBuilderInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @var View
 | 
			
		||||
     */
 | 
			
		||||
    protected $view;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var SecureCRUDFactoryServiceInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $secureCrudFactoryService;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param RequestedUser            $requestedUserRight
 | 
			
		||||
     * @param SecureCRUDFactoryService $secureCrudFactoryService
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(RequestedUser $requestedUserRight, SecureCRUDFactoryService $secureCrudFactoryService)
 | 
			
		||||
    {
 | 
			
		||||
        $this->view = new View();
 | 
			
		||||
        $this->requestedUserRight = $requestedUserRight;
 | 
			
		||||
        $this->secureCrudFactoryService = $secureCrudFactoryService;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @return View
 | 
			
		||||
     */
 | 
			
		||||
    public function getView(): View
 | 
			
		||||
    {
 | 
			
		||||
        $this->secureCrudFactoryService->create($requestedRight);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,16 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ViewManagement;
 | 
			
		||||
 | 
			
		||||
use FOS\RestBundle\View\View;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface ViewBuilderInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @return View
 | 
			
		||||
     */
 | 
			
		||||
    public function getView(): View;
 | 
			
		||||
}
 | 
			
		||||
@@ -5,13 +5,15 @@ namespace App\Entity;
 | 
			
		||||
use App\Entity\Attribut\IdAttribut;
 | 
			
		||||
use Doctrine\ORM\Mapping as ORM;
 | 
			
		||||
use App\Entity\Attribut\VersionAttribut;
 | 
			
		||||
use App\Entity\Attribut\SlugAttribut;
 | 
			
		||||
use Symfony\Component\Validator\Constraints as Assert;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractEntity implements EntityInterface
 | 
			
		||||
{
 | 
			
		||||
    use IdAttribut, VersionAttribut;
 | 
			
		||||
    use IdAttribut, VersionAttribut,SlugAttribut;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @ORM\Id()
 | 
			
		||||
@@ -29,6 +31,21 @@ abstract class AbstractEntity implements EntityInterface
 | 
			
		||||
     */
 | 
			
		||||
    protected $version;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * System slugs should be writen in UPPER CASES
 | 
			
		||||
     * Slugs which are defined by the user are checked via the assert.
 | 
			
		||||
     *
 | 
			
		||||
     * @ORM\Column(type="string",length=30,nullable=true,unique=true)
 | 
			
		||||
     * @Assert\Regex(pattern="/^[a-z]+$/")
 | 
			
		||||
     *
 | 
			
		||||
     * @todo Check out if a plugin can solve this purpose;
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sluggable.md
 | 
			
		||||
     *
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $slug;
 | 
			
		||||
    
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        $this->version = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -4,10 +4,11 @@ namespace App\Entity;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Attribut\VersionAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\IdAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\SlugAttributInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface EntityInterface extends VersionAttributInterface, IdAttributInterface
 | 
			
		||||
interface EntityInterface extends VersionAttributInterface, IdAttributInterface,SlugAttributInterface
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,7 +8,6 @@ use App\Entity\AbstractEntity;
 | 
			
		||||
use App\Entity\Attribut\LawAttribut;
 | 
			
		||||
use App\Entity\Meta\LawInterface;
 | 
			
		||||
use App\Entity\Meta\Law;
 | 
			
		||||
use App\Entity\Attribut\SlugAttribut;
 | 
			
		||||
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
 | 
			
		||||
use Symfony\Component\Validator\Constraints as Assert;
 | 
			
		||||
use App\Entity\Attribut\CreatorRelationAttribut;
 | 
			
		||||
@@ -49,22 +48,7 @@ use App\Entity\Meta\Relation\Member\MemberRelationInterface;
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractSource extends AbstractEntity implements SourceInterface
 | 
			
		||||
{
 | 
			
		||||
    use  LawAttribut,SlugAttribut,CreatorRelationAttribut, MemberRelationAttribut;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * System slugs should be writen in UPPER CASES
 | 
			
		||||
     * Slugs which are defined by the user are checked via the assert.
 | 
			
		||||
     *
 | 
			
		||||
     * @ORM\Column(type="string",length=30,nullable=true,unique=true)
 | 
			
		||||
     * @Assert\Regex(pattern="/^[a-z]+$/")
 | 
			
		||||
     *
 | 
			
		||||
     * @todo Check out if a plugin can solve this purpose;
 | 
			
		||||
     *
 | 
			
		||||
     * @see https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/sluggable.md
 | 
			
		||||
     *
 | 
			
		||||
     * @var string
 | 
			
		||||
     */
 | 
			
		||||
    protected $slug;
 | 
			
		||||
    use  LawAttribut,CreatorRelationAttribut, MemberRelationAttribut;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var CreatorRelationInterface
 | 
			
		||||
 
 | 
			
		||||
@@ -5,13 +5,12 @@ namespace App\Entity\Source;
 | 
			
		||||
use App\Entity\Attribut\IdAttributInterface;
 | 
			
		||||
use App\Entity\EntityInterface;
 | 
			
		||||
use App\Entity\Attribut\LawAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\SlugAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\CreatorRelationAttributInterface;
 | 
			
		||||
use App\Entity\Attribut\MemberRelationAttributInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface SourceInterface extends IdAttributInterface, EntityInterface, LawAttributInterface, SlugAttributInterface, CreatorRelationAttributInterface, MemberRelationAttributInterface
 | 
			
		||||
interface SourceInterface extends IdAttributInterface, EntityInterface, LawAttributInterface, CreatorRelationAttributInterface, MemberRelationAttributInterface
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
namespace App\Repository\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
use App\Domain\RequestManagement\RequestedSourceInterface;
 | 
			
		||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
			
		||||
use App\Repository\AbstractRepository;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -11,6 +11,11 @@ use App\Repository\AbstractRepository;
 | 
			
		||||
 */
 | 
			
		||||
final class SourceRepository extends AbstractRepository implements SourceRepositoryInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Repository\Source\SourceRepositoryInterface::findOneBySlug()
 | 
			
		||||
     */
 | 
			
		||||
    public function findOneBySlug(string $slug): ?SourceInterface
 | 
			
		||||
    {
 | 
			
		||||
        return $this->findOneBy([
 | 
			
		||||
@@ -18,7 +23,12 @@ final class SourceRepository extends AbstractRepository implements SourceReposit
 | 
			
		||||
        ]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function findOneByIdOrSlug(RequestedSourceInterface $requestedSource): ?SourceInterface
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Repository\Source\SourceRepositoryInterface::findOneByIdOrSlug()
 | 
			
		||||
     */
 | 
			
		||||
    public function findOneByIdOrSlug(RequestedEntityInterface $requestedSource): ?SourceInterface
 | 
			
		||||
    {
 | 
			
		||||
        if ($requestedSource->hasId()) {
 | 
			
		||||
            return $this->find($requestedSource->getId());
 | 
			
		||||
 
 | 
			
		||||
@@ -3,7 +3,7 @@
 | 
			
		||||
namespace App\Repository\Source;
 | 
			
		||||
 | 
			
		||||
use App\Entity\Source\SourceInterface;
 | 
			
		||||
use App\Domain\RequestManagement\RequestedSourceInterface;
 | 
			
		||||
use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
			
		||||
use App\Repository\RepositoryInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -23,9 +23,9 @@ interface SourceRepositoryInterface extends RepositoryInterface
 | 
			
		||||
    /**
 | 
			
		||||
     * Loads a source by id or if not defined, by slug.
 | 
			
		||||
     *
 | 
			
		||||
     * @param RequestedSourceInterface $requestedSource
 | 
			
		||||
     * @param RequestedEntityInterface $requestedSource
 | 
			
		||||
     *
 | 
			
		||||
     * @return SourceInterface|null
 | 
			
		||||
     */
 | 
			
		||||
    public function findOneByIdOrSlug(RequestedSourceInterface $requestedSource): ?SourceInterface;
 | 
			
		||||
    public function findOneByIdOrSlug(RequestedEntityInterface $requestedSource): ?SourceInterface;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user