mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-03 18:58:01 +00:00 
			
		
		
		
	Implemented injection of RequestedEntityService to RequestedRightService
This commit is contained in:
		@@ -28,6 +28,14 @@ abstract class AbstractAction extends AbstractActionConstructor implements Actio
 | 
			
		||||
     */
 | 
			
		||||
    abstract protected function proccess();
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * This function can be implemented in the child classes for preparation.
 | 
			
		||||
     */
 | 
			
		||||
    protected function prepare(): void
 | 
			
		||||
    {
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @throws \Exception
 | 
			
		||||
     *
 | 
			
		||||
@@ -37,6 +45,7 @@ abstract class AbstractAction extends AbstractActionConstructor implements Actio
 | 
			
		||||
     */
 | 
			
		||||
    final public function execute()
 | 
			
		||||
    {
 | 
			
		||||
        $this->prepare();
 | 
			
		||||
        if ($this->isSecure()) {
 | 
			
		||||
            if ($this->isValid()) {
 | 
			
		||||
                return $this->proccess();
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ namespace App\Domain\ActionManagement\Create;
 | 
			
		||||
use App\Domain\SourceManagement\SourceClassInformationService;
 | 
			
		||||
use App\Form\Source\SourceType;
 | 
			
		||||
use App\Entity\Source\AbstractSource;
 | 
			
		||||
use Symfony\Component\Form\Form;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -23,15 +24,36 @@ final class CreateSourceAction extends AbstractCreateAction
 | 
			
		||||
     */
 | 
			
		||||
    private $sourceClass;
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @var Form
 | 
			
		||||
     */
 | 
			
		||||
    private $form;
 | 
			
		||||
 | 
			
		||||
    private function setSourceClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        $request = $this->actionService->getRequest();
 | 
			
		||||
        $this->sourceClass = $request->get(SourceType::CLASS_PARAMETER_NAME, self::DEFAULT_CLASS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function prepare(): void
 | 
			
		||||
    private function setFormClass(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->form = $this->actionService->getCurrentFormBuilder()->getForm();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private function handleRequest(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->form->handleRequest($this->actionService->getRequest());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Domain\ActionManagement\AbstractAction::prepare()
 | 
			
		||||
     */
 | 
			
		||||
    protected function prepare(): void
 | 
			
		||||
    {
 | 
			
		||||
        $this->setSourceClass();
 | 
			
		||||
        $this->setFormClass();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
@@ -41,7 +63,7 @@ final class CreateSourceAction extends AbstractCreateAction
 | 
			
		||||
     */
 | 
			
		||||
    protected function isValid(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->actionService->getCurrentFormBuilder()->getForm()->isValid();
 | 
			
		||||
        return $this->form->isValid();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
		 Before Width: | Height: | Size: 296 KiB After Width: | Height: | Size: 297 KiB  | 
@@ -11,6 +11,7 @@ use App\Domain\RequestManagement\Entity\RequestedEntityInterface;
 | 
			
		||||
use App\Attribut\RequestedEntityAttribut;
 | 
			
		||||
use App\Entity\Meta\MetaInterface;
 | 
			
		||||
use App\Exception\NotCorrectInstanceException;
 | 
			
		||||
use App\Domain\RequestManagement\Entity\RequestedEntity;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -56,6 +57,16 @@ class RequestedRight implements RequestedRightInterface
 | 
			
		||||
        throw new PreconditionFailedException(get_class($this->requestedEntity).' needs to have a defined attribut id or slug!');
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @param RequestedEntity|null $requestedEntity
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(?RequestedEntity $requestedEntity = null)
 | 
			
		||||
    {
 | 
			
		||||
        if ($requestedEntity) {
 | 
			
		||||
            $this->setRequestedEntity($requestedEntity);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Uses some kind of Lazy loading.
 | 
			
		||||
     *
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,8 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\RequestManagement\Right;
 | 
			
		||||
 | 
			
		||||
use App\Domain\RequestManagement\Entity\RequestedEntityServiceInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Allows to use a right as a Service.
 | 
			
		||||
 *
 | 
			
		||||
@@ -9,4 +11,11 @@ namespace App\Domain\RequestManagement\Right;
 | 
			
		||||
 */
 | 
			
		||||
final class RequestedRightService extends RequestedRight implements RequestedRightServiceInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * @param RequestedEntityServiceInterface $requestedEntityService
 | 
			
		||||
     */
 | 
			
		||||
    public function __construct(RequestedEntityServiceInterface $requestedEntityService)
 | 
			
		||||
    {
 | 
			
		||||
        parent::__construct($requestedEntityService);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user