mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Optimized logic for source.html.twig
This commit is contained in:
parent
c702ddf211
commit
15f9925e66
@ -9,6 +9,11 @@ use Infinito\Domain\RequestManagement\Action\RequestedActionServiceInterface;
|
||||
*/
|
||||
class TemplateNameService implements TemplateNameServiceInterface
|
||||
{
|
||||
/**
|
||||
* @var unknown
|
||||
*/
|
||||
const BASE_TEMPLATE_DIR = __DIR__.'/../../../templates/';
|
||||
|
||||
/**
|
||||
* @var string The namespace which should be ignored
|
||||
*/
|
||||
@ -71,7 +76,7 @@ class TemplateNameService implements TemplateNameServiceInterface
|
||||
$origineClass = $this->getClass();
|
||||
$baseReplaced = str_replace(self::BASE_NAMESPACE, self::BASE_ENTITY_TEMPLATE_FOLDER, $origineClass);
|
||||
$elements = explode('\\', $baseReplaced);
|
||||
array_pop($elements); //Removes class name
|
||||
array_pop($elements); // Removes class name
|
||||
$templatePath = implode('/', $elements);
|
||||
$lowerCasePath = strtolower($templatePath);
|
||||
|
||||
@ -130,4 +135,29 @@ class TemplateNameService implements TemplateNameServiceInterface
|
||||
{
|
||||
return $this->getTemplatePath(self::MOLECULE_PRAEFFIX);
|
||||
}
|
||||
|
||||
private function templateExists(string $template): bool
|
||||
{
|
||||
return file_exists(self::BASE_TEMPLATE_DIR.$template);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TemplateManagement\TemplateNameServiceInterface::doesAtomTemplateExists()
|
||||
*/
|
||||
public function doesAtomTemplateExist(): bool
|
||||
{
|
||||
return $this->templateExists($this->getAtomTemplateName());
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* @see \Infinito\Domain\TemplateManagement\TemplateNameServiceInterface::doesMoleculeTemplateExists()
|
||||
*/
|
||||
public function doesMoleculeTemplateExist(): bool
|
||||
{
|
||||
return $this->templateExists($this->getMoleculeTemplateName());
|
||||
}
|
||||
}
|
||||
|
@ -16,4 +16,14 @@ interface TemplateNameServiceInterface
|
||||
* @return string a template without a frame
|
||||
*/
|
||||
public function getAtomTemplateName(): string;
|
||||
|
||||
/**
|
||||
* @return bool True if template exists
|
||||
*/
|
||||
public function doesAtomTemplateExist(): bool;
|
||||
|
||||
/**
|
||||
* @return bool True if template exists
|
||||
*/
|
||||
public function doesMoleculeTemplateExist(): bool;
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
{{ entity.text }}
|
@ -8,52 +8,30 @@
|
||||
</h1>
|
||||
<div id="accordion">
|
||||
{% for action in layer_action_map.getActions('source') %}
|
||||
<div class="card">
|
||||
<div class="card-header" id="heading_{{ action }}">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-link collapsed" data-toggle="collapse"
|
||||
data-target="#collapse_{{ action }}" aria-expanded="false"
|
||||
aria-controls="collapse_{{ action }}">
|
||||
<i class="{{ action_icon_class_map.getIconClass(action) }}"></i> {{ action|trans }}
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="collapse_{{ action }}" class="collapse"
|
||||
aria-labelledby="heading_{{ action }}" 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>
|
||||
|
||||
{{ action_template_name_service.setActionType(action) }}
|
||||
{% if action_template_name_service.doesAtomTemplateExist() %}
|
||||
<div class="card">
|
||||
<div class="card-header" id="heading_{{ action }}">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-link collapsed" data-toggle="collapse"
|
||||
data-target="#collapse_{{ action }}" aria-expanded="false"
|
||||
aria-controls="collapse_{{ action }}">
|
||||
<i class="{{ action_icon_class_map.getIconClass(action) }}"></i> {{ action|trans }}
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="collapse_{{ action }}" class="collapse"
|
||||
aria-labelledby="heading_{{ action }}" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
{% include action_template_name_service.getAtomTemplateName() %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
<hr />
|
||||
<div id="accordion">
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingOne">
|
||||
<h5 class="mb-0">
|
||||
<button class="btn btn-link" data-toggle="collapse"
|
||||
data-target="#collapseOne" aria-expanded="true"
|
||||
aria-controls="collapseOne">
|
||||
<i class="fas fa-glasses"></i> Read
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
<div id="collapseOne" class="collapse show"
|
||||
aria-labelledby="headingOne" data-parent="#accordion">
|
||||
<div class="card-body">
|
||||
{{ entity.text }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-header" id="headingThree">
|
||||
<h5 class="mb-0">
|
||||
|
Loading…
Reference in New Issue
Block a user