Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/services.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use App\Twig\ContentExtension;
use SumoCoders\FrameworkCoreBundle\Command\TranslateCommand;
use Symfony\Component\Form\Extension\Core\Type\TimeType;
use SumoCoders\FrameworkCoreBundle\Service\Fallbacks;
Expand Down Expand Up @@ -101,6 +102,9 @@
->set('framework.paginator_runtime', PaginatorRuntime::class)
->tag('twig.runtime')

->set('framework.content_extension', ContentExtension::class)
->tag('twig.extension')

/*
* Breadcrumbs
*/
Expand Down
28 changes: 28 additions & 0 deletions src/Twig/ContentExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace App\Twig;

use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

class ContentExtension extends AbstractExtension
{
public function __construct(
#[Autowire('%kernel.project_dir%/public')]
private string $publicFolder
) {
}

public function getFunctions(): array
{
return [
new TwigFunction('content', [$this, 'getContent'], ['is_safe' => ['html']]),
];
}

public function getContent(string $path): string
{
return file_get_contents($this->publicFolder . $path);
}
}
2 changes: 1 addition & 1 deletion templates/Mail/base.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% apply inky_to_html|inline_css(source(asset('build/mail.css'))) %}
{% apply inky_to_html|inline_css(content(asset('build/mail.css'))) %}
<spacer size="16"></spacer>
<container>
<spacer size="16"></spacer>
Expand Down