mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-11-04 03:07:58 +00:00 
			
		
		
		
	Optimized Actions, Tests and renamed LIST to THREAD out of php incompatibility reasons
This commit is contained in:
		@@ -11,13 +11,13 @@ use App\DBAL\Types\Meta\Right\CRUDType;
 | 
			
		||||
 */
 | 
			
		||||
final class ActionType extends CRUDType
 | 
			
		||||
{
 | 
			
		||||
    const LIST = 'list';
 | 
			
		||||
    const THREAD = 'thread';
 | 
			
		||||
 | 
			
		||||
    protected static $choices = [
 | 
			
		||||
        parent::CREATE => 'create',
 | 
			
		||||
        parent::READ => 'read',
 | 
			
		||||
        parent::UPDATE => 'update',
 | 
			
		||||
        parent::DELETE => 'delete',
 | 
			
		||||
        self::LIST => 'list',
 | 
			
		||||
        self::THREAD => 'thread',
 | 
			
		||||
    ];
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -7,6 +7,15 @@ use App\Domain\ActionManagement\AbstractAction;
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractCreateAction extends AbstractAction
 | 
			
		||||
abstract class AbstractCreateAction extends AbstractAction implements CreateActionInterface
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Domain\ActionManagement\AbstractAction::isSecure()
 | 
			
		||||
     */
 | 
			
		||||
    protected function isSecure(): bool
 | 
			
		||||
    {
 | 
			
		||||
        return $this->actionService->isRequestedActionSecure();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ActionManagement\Create;
 | 
			
		||||
 | 
			
		||||
use App\Domain\ActionManagement\ActionInterface;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
interface CreateActionInterface extends ActionInterface
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -7,10 +7,6 @@ namespace App\Domain\ActionManagement\Create;
 | 
			
		||||
 */
 | 
			
		||||
final class CreateSourceAction extends AbstractCreateAction
 | 
			
		||||
{
 | 
			
		||||
    protected function isSecure(): bool
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function isValidByForm(): bool
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ActionManagement\Thread;
 | 
			
		||||
 | 
			
		||||
use App\Domain\ActionManagement\AbstractAction;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractThreadAction extends AbstractAction
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,26 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ActionManagement\Thread;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
final class ThreadSourceAction extends AbstractThreadAction
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * {@inheritdoc}
 | 
			
		||||
     *
 | 
			
		||||
     * @see \App\Domain\ActionManagement\AbstractAction::isSecure()
 | 
			
		||||
     */
 | 
			
		||||
    protected function isSecure(): bool
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function isValidByForm(): bool
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function proccess()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
<?php
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ActionManagement\Update;
 | 
			
		||||
 | 
			
		||||
use App\Domain\ActionManagement\AbstractAction;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
abstract class AbstractUpdateAction extends AbstractAction
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
@@ -2,6 +2,20 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Domain\ActionManagement\Update;
 | 
			
		||||
 | 
			
		||||
class UpdateSourceAction
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
 */
 | 
			
		||||
final class UpdateSourceAction extends AbstractUpdateAction
 | 
			
		||||
{
 | 
			
		||||
    protected function isSecure(): bool
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function isValidByForm(): bool
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected function proccess()
 | 
			
		||||
    {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,7 @@ final class LayerActionMap implements LayerActionMapInterface
 | 
			
		||||
            ActionType::CREATE,
 | 
			
		||||
            ActionType::UPDATE,
 | 
			
		||||
            ActionType::DELETE,
 | 
			
		||||
            ActionType::LIST,
 | 
			
		||||
            ActionType::THREAD,
 | 
			
		||||
        ],
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,7 @@ class RequestedAction extends RequestedUser implements RequestedActionInterface
 | 
			
		||||
     * @var array Containes the mapping of non standard actions to a crud
 | 
			
		||||
     */
 | 
			
		||||
    const ACTION_CRUD_MAP = [
 | 
			
		||||
        ActionType::LIST => CRUDType::READ,
 | 
			
		||||
        ActionType::THREAD => CRUDType::READ,
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -2,16 +2,15 @@
 | 
			
		||||
 | 
			
		||||
namespace tests\Unit\Domain\SecureCRUDManagement\Factory;
 | 
			
		||||
 | 
			
		||||
use App\DBAL\Types\Meta\Right\LayerType;
 | 
			
		||||
use PHPUnit\Framework\TestCase;
 | 
			
		||||
use App\Domain\ActionManagement\ActionFactoryServiceInterface;
 | 
			
		||||
use App\Domain\ActionManagement\ActionFactoryService;
 | 
			
		||||
use App\Domain\ActionManagement\ActionServiceInterface;
 | 
			
		||||
use App\DBAL\Types\ActionType;
 | 
			
		||||
use App\Domain\ActionManagement\ActionInterface;
 | 
			
		||||
use App\Domain\RequestManagement\Action\RequestedActionInterface;
 | 
			
		||||
use App\Domain\RequestManagement\Action\RequestedAction;
 | 
			
		||||
use App\Domain\RequestManagement\Right\RequestedRight;
 | 
			
		||||
use App\Domain\LayerManagement\LayerActionMap;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author kevinfrantz
 | 
			
		||||
@@ -44,8 +43,8 @@ class ActionFactoryServiceTest extends TestCase
 | 
			
		||||
 | 
			
		||||
    public function testCreate(): void
 | 
			
		||||
    {
 | 
			
		||||
        foreach (ActionType::getChoices() as $action) {
 | 
			
		||||
            foreach (LayerType::getChoices() as $layer) {
 | 
			
		||||
        foreach (LayerActionMap::LAYER_ACTION_MAP as $layer => $actions) {
 | 
			
		||||
            foreach ($actions as $action) {
 | 
			
		||||
                $this->requestedAction->setLayer($layer);
 | 
			
		||||
                $this->requestedAction->setActionType($action);
 | 
			
		||||
                $result = $this->actionFactoryService->create();
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ class RequestedActionTest extends TestCase
 | 
			
		||||
 | 
			
		||||
    public function testList(): void
 | 
			
		||||
    {
 | 
			
		||||
        $list = ActionType::LIST;
 | 
			
		||||
        $list = ActionType::THREAD;
 | 
			
		||||
        $this->action->setActionType($list);
 | 
			
		||||
        $this->assertEquals($list, $this->action->getActionType());
 | 
			
		||||
        $this->assertEquals(CRUDType::READ, $this->requestedRight->getCrud());
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user