mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-18 19:09:20 +02:00
Implemented functions for optimizing source.html.twig
This commit is contained in:
parent
d99c05908b
commit
a117d16429
@ -3,3 +3,6 @@ twig:
|
|||||||
debug: '%kernel.debug%'
|
debug: '%kernel.debug%'
|
||||||
strict_variables: '%kernel.debug%'
|
strict_variables: '%kernel.debug%'
|
||||||
form_themes: ['bootstrap_4_layout.html.twig']
|
form_themes: ['bootstrap_4_layout.html.twig']
|
||||||
|
globals:
|
||||||
|
layer_action_map: "@Infinito\\Domain\\LayerManagement\\LayerActionMap"
|
||||||
|
action_icon_class_map: "@Infinito\\Domain\\TwigManagement\\ActionIconClassMap"
|
||||||
|
@ -11,13 +11,19 @@ use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
|||||||
*/
|
*/
|
||||||
final class ActionType extends CRUDType
|
final class ActionType extends CRUDType
|
||||||
{
|
{
|
||||||
const THREAD = 'thread';
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
const EXECUTE = 'execute';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
protected static $choices = [
|
protected static $choices = [
|
||||||
parent::CREATE => 'create',
|
parent::CREATE => 'create',
|
||||||
parent::READ => 'read',
|
parent::READ => 'read',
|
||||||
parent::UPDATE => 'update',
|
parent::UPDATE => 'update',
|
||||||
parent::DELETE => 'delete',
|
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
|
<?php
|
||||||
|
|
||||||
namespace Infinito\Domain\ActionManagement\Thread;
|
namespace Infinito\Domain\ActionManagement\Execute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
final class ThreadSourceAction extends AbstractThreadAction
|
final class ExecuteAction extends AbstractExecuteAction
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@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::CREATE,
|
||||||
ActionType::UPDATE,
|
ActionType::UPDATE,
|
||||||
ActionType::DELETE,
|
ActionType::DELETE,
|
||||||
ActionType::THREAD,
|
ActionType::EXECUTE,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
@ -13,6 +13,9 @@ use Infinito\Entity\Meta\Right;
|
|||||||
*/
|
*/
|
||||||
final class LayerClassMap implements LayerClassMapInterface
|
final class LayerClassMap implements LayerClassMapInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var array|string[]
|
||||||
|
*/
|
||||||
const LAYER_CLASS_MAP = [
|
const LAYER_CLASS_MAP = [
|
||||||
LayerType::SOURCE => AbstractSource::class,
|
LayerType::SOURCE => AbstractSource::class,
|
||||||
LayerType::LAW => Law::class,
|
LayerType::LAW => Law::class,
|
||||||
|
@ -26,7 +26,7 @@ final class ActionHttpMethodMap extends AbstractMap implements ActionHttpMethodM
|
|||||||
Request::METHOD_GET,
|
Request::METHOD_GET,
|
||||||
Request::METHOD_DELETE,
|
Request::METHOD_DELETE,
|
||||||
],
|
],
|
||||||
ActionType::THREAD => [
|
ActionType::EXECUTE => [
|
||||||
Request::METHOD_GET,
|
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
|
* @var array Containes the mapping of non standard actions to a crud
|
||||||
*/
|
*/
|
||||||
const ACTION_CRUD_MAP = [
|
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;
|
||||||
|
}
|
@ -1,26 +1,25 @@
|
|||||||
{% extends "frames/default.html.twig" %}
|
{% extends "frames/default.html.twig" %}
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% trans %}
|
{{ 'Source'|trans }}: {% if entity.hasSlug %}{{ entity.slug }}{% endif %}#{{ entity.id }}
|
||||||
Source
|
|
||||||
{% endtrans %}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>
|
<h1>
|
||||||
Source: {% if entity.hasSlug %}{{ entity.slug }}{% endif %}#{{ entity.id }}
|
{{ 'Source'|trans }}: {% if entity.hasSlug %}{{ entity.slug }}{% endif %}#{{ entity.id }}
|
||||||
</h1>
|
</h1>
|
||||||
<div id="accordion">
|
<div id="accordion">
|
||||||
|
{% for action in layer_action_map.getActions('source') %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header" id="headingExecute">
|
<div class="card-header" id="heading_{{ action }}">
|
||||||
<h5 class="mb-0">
|
<h5 class="mb-0">
|
||||||
<button class="btn btn-link collapsed" data-toggle="collapse"
|
<button class="btn btn-link collapsed" data-toggle="collapse"
|
||||||
data-target="#collapseExecute" aria-expanded="false"
|
data-target="#collapse_{{ action }}" aria-expanded="false"
|
||||||
aria-controls="collapseExecute">
|
aria-controls="collapse_{{ action }}">
|
||||||
<i class="fas fa-microchip"></i> Execute
|
<i class="{{ action_icon_class_map.getIconClass(action) }}"></i> {{ action|trans }}
|
||||||
</button>
|
</button>
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
<div id="collapseExecute" class="collapse"
|
<div id="collapse_{{ action }}" class="collapse"
|
||||||
aria-labelledby="headingExecute" data-parent="#accordion">
|
aria-labelledby="heading_{{ action }}" data-parent="#accordion">
|
||||||
<div class="card-body">Anim pariatur cliche reprehenderit, enim
|
<div class="card-body">Anim pariatur cliche reprehenderit, enim
|
||||||
eiusmod high life accusamus terry richardson ad squid. 3 wolf moon
|
eiusmod high life accusamus terry richardson ad squid. 3 wolf moon
|
||||||
officia aute, non cupidatat skateboard dolor brunch. Food truck
|
officia aute, non cupidatat skateboard dolor brunch. Food truck
|
||||||
@ -33,6 +32,11 @@ Source
|
|||||||
accusamus labore sustainable VHS.</div>
|
accusamus labore sustainable VHS.</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<div id="accordion">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header" id="headingOne">
|
<div class="card-header" id="headingOne">
|
||||||
<h5 class="mb-0">
|
<h5 class="mb-0">
|
||||||
@ -50,54 +54,6 @@ Source
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
|
||||||
<div class="card-header" id="headingTwo">
|
|
||||||
<h5 class="mb-0">
|
|
||||||
<button class="btn btn-link collapsed" data-toggle="collapse"
|
|
||||||
data-target="#collapseTwo" aria-expanded="false"
|
|
||||||
aria-controls="collapseTwo">
|
|
||||||
<i class="fas fa-pencil-alt"></i> Update
|
|
||||||
</button>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo"
|
|
||||||
data-parent="#accordion">
|
|
||||||
<div class="card-body">Anim pariatur cliche reprehenderit, enim
|
|
||||||
eiusmod high life accusamus terry richardson ad squid. 3 wolf moon
|
|
||||||
officia aute, non cupidatat skateboard dolor brunch. Food truck
|
|
||||||
quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt
|
|
||||||
aliqua put a bird on it squid single-origin coffee nulla assumenda
|
|
||||||
shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes
|
|
||||||
anderson cred nesciunt sapiente ea proident. Ad vegan excepteur
|
|
||||||
butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw
|
|
||||||
denim aesthetic synth nesciunt you probably haven't heard of them
|
|
||||||
accusamus labore sustainable VHS.</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header" id="headingDelete">
|
|
||||||
<h5 class="mb-0">
|
|
||||||
<button class="btn btn-link collapsed" data-toggle="collapse"
|
|
||||||
data-target="#collapseDelete" aria-expanded="false"
|
|
||||||
aria-controls="collapseDelete">
|
|
||||||
<i class="fas fa-trash-alt"></i> Delete
|
|
||||||
</button>
|
|
||||||
</h5>
|
|
||||||
</div>
|
|
||||||
<div id="collapseDelete" class="collapse"
|
|
||||||
aria-labelledby="headingDelete" data-parent="#accordion">
|
|
||||||
<div class="card-body">Anim pariatur cliche reprehenderit, enim
|
|
||||||
eiusmod high life accusamus terry richardson ad squid. 3 wolf moon
|
|
||||||
officia aute, non cupidatat skateboard dolor brunch. Food truck
|
|
||||||
quinoa nesciunt laborum eiusmod. Brunch 3 wolf moon tempor, sunt
|
|
||||||
aliqua put a bird on it squid single-origin coffee nulla assumenda
|
|
||||||
shoreditch et. Nihil anim keffiyeh helvetica, craft beer labore wes
|
|
||||||
anderson cred nesciunt sapiente ea proident. Ad vegan excepteur
|
|
||||||
butcher vice lomo. Leggings occaecat craft beer farm-to-table, raw
|
|
||||||
denim aesthetic synth nesciunt you probably haven't heard of them
|
|
||||||
accusamus labore sustainable VHS.</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header" id="headingThree">
|
<div class="card-header" id="headingThree">
|
||||||
<h5 class="mb-0">
|
<h5 class="mb-0">
|
||||||
|
@ -30,7 +30,7 @@ class RequestedActionServiceIntegrationTest extends KernelTestCase
|
|||||||
|
|
||||||
public function testActionAccessors(): void
|
public function testActionAccessors(): void
|
||||||
{
|
{
|
||||||
$actionType = ActionType::THREAD;
|
$actionType = ActionType::EXECUTE;
|
||||||
$this->assertNull($this->requestedActionService->setActionType($actionType));
|
$this->assertNull($this->requestedActionService->setActionType($actionType));
|
||||||
$this->assertEquals($actionType, $this->requestedActionService->getActionType());
|
$this->assertEquals($actionType, $this->requestedActionService->getActionType());
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class RequestedActionTest extends TestCase
|
|||||||
|
|
||||||
public function testList(): void
|
public function testList(): void
|
||||||
{
|
{
|
||||||
$list = ActionType::THREAD;
|
$list = ActionType::EXECUTE;
|
||||||
$this->action->setActionType($list);
|
$this->action->setActionType($list);
|
||||||
$this->assertEquals($list, $this->action->getActionType());
|
$this->assertEquals($list, $this->action->getActionType());
|
||||||
$this->assertEquals(CRUDType::READ, $this->requestedRight->getCrud());
|
$this->assertEquals(CRUDType::READ, $this->requestedRight->getCrud());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user