Release 2.57 (#5929)
This commit is contained in:
@@ -12,6 +12,7 @@ namespace App\Twig\Runtime;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Symfony\Contracts\Service\ServiceSubscriberInterface;
|
||||
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
|
||||
use Twig\Error\RuntimeError;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
|
||||
final class EncoreExtension implements RuntimeExtensionInterface, ServiceSubscriberInterface
|
||||
@@ -32,12 +33,19 @@ final class EncoreExtension implements RuntimeExtensionInterface, ServiceSubscri
|
||||
|
||||
public function getEncoreEntryCssSource(string $packageName): string
|
||||
{
|
||||
if (!\in_array($packageName, ['invoice', 'invoice-pdf', 'export-pdf'])) {
|
||||
throw new RuntimeError('Unknown CSS package requested: ' . $packageName);
|
||||
}
|
||||
|
||||
$lookup = $this->container->get(EntrypointLookupInterface::class);
|
||||
$files = $lookup->getCssFiles($packageName);
|
||||
|
||||
$source = '';
|
||||
|
||||
foreach ($files as $file) {
|
||||
if (!str_ends_with($file, '.css') || str_contains($file, '..')) {
|
||||
continue;
|
||||
}
|
||||
$source .= file_get_contents($this->projectDirectory . '/public/' . $file);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user