mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 21:57:16 +02:00
Implemented functions for optimizing source.html.twig
This commit is contained in:
@@ -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