| Total Complexity | 5 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 20 | class EncoreEmailTwigExtension extends AbstractExtension implements ServiceSubscriberInterface |
||
| 21 | { |
||
| 22 | private $container; |
||
| 23 | private $publicDir; |
||
| 24 | |||
| 25 | public function __construct(ContainerInterface $container, string $publicDir) |
||
| 26 | { |
||
| 27 | $this->container = $container; |
||
| 28 | $this->publicDir = $publicDir; |
||
| 29 | } |
||
| 30 | |||
| 31 | public function getFunctions(): array |
||
| 32 | { |
||
| 33 | return [ |
||
| 34 | new TwigFunction('encore_entry_css_source', [$this, 'getEncoreEntryCssSource']), |
||
| 35 | ]; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function getEncoreEntryCssSource(string $entryName): string |
||
| 39 | { |
||
| 40 | $files = $this->container |
||
| 41 | ->get(EntrypointLookupInterface::class) |
||
| 42 | ->getCssFiles($entryName); |
||
| 43 | |||
| 44 | $source = ''; |
||
| 45 | foreach ($files as $file) { |
||
| 46 | $source .= file_get_contents($this->publicDir.'/'.$file); |
||
| 47 | } |
||
| 48 | |||
| 49 | return $source; |
||
| 50 | } |
||
| 51 | |||
| 52 | public static function getSubscribedServices() |
||
| 56 | ]; |
||
| 57 | } |
||
| 58 | } |
||
| 59 |