container = $container; $this->publicDir = $projectDirectory . '/public'; } public static function getSubscribedServices() { return [ EntrypointLookupInterface::class, ]; } /** * {@inheritdoc} */ public function getFunctions() { return [ new TwigFunction('encore_entry_css_source', [$this, 'getEncoreEntryCssSource']), ]; } public function getEncoreEntryCssSource(string $packageName): string { $files = $this->container ->get(EntrypointLookupInterface::class)->getCssFiles($packageName); $source = ''; foreach ($files as $file) { $source .= file_get_contents($this->publicDir . '/' . $file); } return $source; } }