for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the TheAlternativeZurich/events project.
*
* (c) Florian Moser <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace App\Extension;
use Psr\Container\ContainerInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class EncoreEmailTwigExtension extends AbstractExtension implements ServiceSubscriberInterface
{
private $container;
private $publicDir;
public function __construct(ContainerInterface $container, string $publicDir)
$this->container = $container;
$this->publicDir = $publicDir;
}
public function getFunctions(): array
return [
new TwigFunction('encore_entry_css_source', [$this, 'getEncoreEntryCssSource']),
];
public function getEncoreEntryCssSource(string $entryName): string
$files = $this->container
->get(EntrypointLookupInterface::class)
->getCssFiles($entryName);
$source = '';
foreach ($files as $file) {
$source .= file_get_contents($this->publicDir.'/'.$file);
return $source;
public static function getSubscribedServices()
EntrypointLookupInterface::class,