7 changed files with 64 additions and 2 deletions
@ -0,0 +1,25 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
namespace App\Twig; |
||||||
|
|
||||||
|
use Symfony\Component\Yaml\Yaml; |
||||||
|
use Twig\Extension\AbstractExtension; |
||||||
|
use Twig\Extension\GlobalsInterface; |
||||||
|
|
||||||
|
class FooterLinksExtension extends AbstractExtension implements GlobalsInterface |
||||||
|
{ |
||||||
|
private array $footerLinks; |
||||||
|
|
||||||
|
public function __construct(string $footerLinksPath) |
||||||
|
{ |
||||||
|
$config = Yaml::parseFile($footerLinksPath); |
||||||
|
$this->footerLinks = $config['parameters']['external_links'] ?? []; |
||||||
|
} |
||||||
|
|
||||||
|
public function getGlobals(): array |
||||||
|
{ |
||||||
|
return [ |
||||||
|
'footer_links' => $this->footerLinks, |
||||||
|
]; |
||||||
|
} |
||||||
|
} |
||||||
@ -1 +1,13 @@ |
|||||||
|
<div class="footer-links"> |
||||||
|
{% for link in footer_links %} |
||||||
|
<div class="footer-link"> |
||||||
|
<a href="{{ link.url }}" target="_blank" rel="noopener noreferrer" title="{{ link.description|default(link.title) }}">{{ link.title }}</a> |
||||||
|
{% if link.description %} |
||||||
|
— <small>{{ link.description }}</small> |
||||||
|
{% endif %} |
||||||
|
</div> |
||||||
|
{% endfor %} |
||||||
|
</div> |
||||||
|
|
||||||
<p>{{ "now"|date("Y") }} {{ website_name }}</p> |
<p>{{ "now"|date("Y") }} {{ website_name }}</p> |
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue