mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-04-18 19:09:20 +02: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
|
class TemplateNameService implements TemplateNameServiceInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var unknown
|
||||||
|
*/
|
||||||
|
const BASE_TEMPLATE_DIR = __DIR__.'/../../../templates/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string The namespace which should be ignored
|
* @var string The namespace which should be ignored
|
||||||
*/
|
*/
|
||||||
@ -71,7 +76,7 @@ class TemplateNameService implements TemplateNameServiceInterface
|
|||||||
$origineClass = $this->getClass();
|
$origineClass = $this->getClass();
|
||||||
$baseReplaced = str_replace(self::BASE_NAMESPACE, self::BASE_ENTITY_TEMPLATE_FOLDER, $origineClass);
|
$baseReplaced = str_replace(self::BASE_NAMESPACE, self::BASE_ENTITY_TEMPLATE_FOLDER, $origineClass);
|
||||||
$elements = explode('\\', $baseReplaced);
|
$elements = explode('\\', $baseReplaced);
|
||||||
array_pop($elements); //Removes class name
|
array_pop($elements); // Removes class name
|
||||||
$templatePath = implode('/', $elements);
|
$templatePath = implode('/', $elements);
|
||||||
$lowerCasePath = strtolower($templatePath);
|
$lowerCasePath = strtolower($templatePath);
|
||||||
|
|
||||||
@ -130,4 +135,29 @@ class TemplateNameService implements TemplateNameServiceInterface
|
|||||||
{
|
{
|
||||||
return $this->getTemplatePath(self::MOLECULE_PRAEFFIX);
|
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
|
* @return string a template without a frame
|
||||||
*/
|
*/
|
||||||
public function getAtomTemplateName(): string;
|
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,6 +8,8 @@
|
|||||||
</h1>
|
</h1>
|
||||||
<div id="accordion">
|
<div id="accordion">
|
||||||
{% for action in layer_action_map.getActions('source') %}
|
{% for action in layer_action_map.getActions('source') %}
|
||||||
|
{{ action_template_name_service.setActionType(action) }}
|
||||||
|
{% if action_template_name_service.doesAtomTemplateExist() %}
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header" id="heading_{{ action }}">
|
<div class="card-header" id="heading_{{ action }}">
|
||||||
<h5 class="mb-0">
|
<h5 class="mb-0">
|
||||||
@ -20,40 +22,16 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="collapse_{{ action }}" class="collapse"
|
<div id="collapse_{{ action }}" class="collapse"
|
||||||
aria-labelledby="heading_{{ action }}" data-parent="#accordion">
|
aria-labelledby="heading_{{ action }}" data-parent="#accordion">
|
||||||
<div class="card-body">Anim pariatur cliche reprehenderit, enim
|
<div class="card-body">
|
||||||
eiusmod high life accusamus terry richardson ad squid. 3 wolf moon
|
{% include action_template_name_service.getAtomTemplateName() %}
|
||||||
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>
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div id="accordion">
|
<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">
|
||||||
<div class="card-header" id="headingThree">
|
<div class="card-header" id="headingThree">
|
||||||
<h5 class="mb-0">
|
<h5 class="mb-0">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user