mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Implemented functions for optimizing source.html.twig
This commit is contained in:
@@ -11,13 +11,19 @@ use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
||||
*/
|
||||
final class ActionType extends CRUDType
|
||||
{
|
||||
const THREAD = 'thread';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const EXECUTE = 'execute';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $choices = [
|
||||
parent::CREATE => 'create',
|
||||
parent::READ => 'read',
|
||||
parent::UPDATE => 'update',
|
||||
parent::DELETE => 'delete',
|
||||
self::THREAD => 'thread',
|
||||
self::EXECUTE => 'execute',
|
||||
];
|
||||
}
|
||||
|
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\ActionManagement\Execute;
|
||||
|
||||
use Infinito\Domain\ActionManagement\AbstractAction;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractExecuteAction extends AbstractAction
|
||||
{
|
||||
}
|
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\ActionManagement\Thread;
|
||||
namespace Infinito\Domain\ActionManagement\Execute;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ThreadSourceAction extends AbstractThreadAction
|
||||
final class ExecuteAction extends AbstractExecuteAction
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
@@ -1,12 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\ActionManagement\Thread;
|
||||
|
||||
use Infinito\Domain\ActionManagement\AbstractAction;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractThreadAction extends AbstractAction
|
||||
{
|
||||
}
|
@@ -20,7 +20,7 @@ final class LayerActionMap extends AbstractMap implements LayerActionMapInterfac
|
||||
ActionType::CREATE,
|
||||
ActionType::UPDATE,
|
||||
ActionType::DELETE,
|
||||
ActionType::THREAD,
|
||||
ActionType::EXECUTE,
|
||||
],
|
||||
];
|
||||
|
||||
|
@@ -13,6 +13,9 @@ use Infinito\Entity\Meta\Right;
|
||||
*/
|
||||
final class LayerClassMap implements LayerClassMapInterface
|
||||
{
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
const LAYER_CLASS_MAP = [
|
||||
LayerType::SOURCE => AbstractSource::class,
|
||||
LayerType::LAW => Law::class,
|
||||
|
@@ -26,7 +26,7 @@ final class ActionHttpMethodMap extends AbstractMap implements ActionHttpMethodM
|
||||
Request::METHOD_GET,
|
||||
Request::METHOD_DELETE,
|
||||
],
|
||||
ActionType::THREAD => [
|
||||
ActionType::EXECUTE => [
|
||||
Request::METHOD_GET,
|
||||
],
|
||||
];
|
||||
|
@@ -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::THREAD => CRUDType::READ,
|
||||
ActionType::EXECUTE => CRUDType::READ,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\TwigManagement;
|
||||
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
use Infinito\Exception\NotSetException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
final class ActionIconClassMap implements ActionIconClassMapInterface
|
||||
{
|
||||
/**
|
||||
* @var array|string[]
|
||||
*/
|
||||
const ACTION_ICON_CLASS_MAP = [
|
||||
ActionType::READ => 'fas fa-glasses',
|
||||
ActionType::EXECUTE => 'fas fa-microchip',
|
||||
ActionType::UPDATE => 'fas fa-pencil-alt',
|
||||
ActionType::DELETE => 'fas fa-trash-alt',
|
||||
ActionType::CREATE => 'fas fa-plus-square',
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TwigManagement\ActionIconClassMapInterface::getIconClass()
|
||||
*/
|
||||
public function getIconClass(string $action): string
|
||||
{
|
||||
if (key_exists($action, self::ACTION_ICON_CLASS_MAP)) {
|
||||
return self::ACTION_ICON_CLASS_MAP[$action];
|
||||
}
|
||||
throw new NotSetException("The key <<$action>> is not defined in the map!");
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Infinito\Domain\TwigManagement;
|
||||
|
||||
/**
|
||||
* Maps actions to classes.
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface ActionIconClassMapInterface
|
||||
{
|
||||
/**
|
||||
* @param string $action
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getIconClass(string $action): string;
|
||||
}
|
Reference in New Issue
Block a user