Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements #181

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Asset/EntrypointLookup.php
Expand Up @@ -127,11 +127,11 @@ private function getEntriesData(): array
$this->entriesData = json_decode(file_get_contents($this->entrypointJsonPath), true);

if (null === $this->entriesData) {
throw new \InvalidArgumentException(sprintf('There was a problem JSON decoding the "%s" file', $this->entrypointJsonPath));
throw new \InvalidArgumentException(sprintf('There was a problem JSON decoding the "%s" file.', $this->entrypointJsonPath));
}

if (!isset($this->entriesData['entrypoints'])) {
throw new \InvalidArgumentException(sprintf('Could not find an "entrypoints" key in the "%s" file', $this->entrypointJsonPath));
throw new \InvalidArgumentException(sprintf('Could not find an "entrypoints" key in the "%s" file.', $this->entrypointJsonPath));
}

if ($this->cache) {
Expand Down
2 changes: 0 additions & 2 deletions src/EventListener/ResetAssetsEventListener.php
@@ -1,7 +1,5 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Symfony WebpackEncoreBundle package.
* (c) Fabien Potencier <fabien@symfony.com>
Expand Down
11 changes: 10 additions & 1 deletion src/Twig/EntryFilesTwigExtension.php
Expand Up @@ -10,13 +10,14 @@
namespace Symfony\WebpackEncoreBundle\Twig;

use Psr\Container\ContainerInterface;
use Symfony\Contracts\Service\ServiceSubscriberInterface;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookup;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
use Symfony\WebpackEncoreBundle\Asset\TagRenderer;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;

final class EntryFilesTwigExtension extends AbstractExtension
final class EntryFilesTwigExtension extends AbstractExtension implements ServiceSubscriberInterface
{
private $container;

Expand Down Expand Up @@ -80,4 +81,12 @@ private function getTagRenderer(): TagRenderer
{
return $this->container->get('webpack_encore.tag_renderer');
}

public static function getSubscribedServices(): array
{
return [
'webpack_encore.entrypoint_lookup_collection' => EntrypointLookupInterface::class,
'webpack_encore.tag_renderer' => TagRenderer::class,
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of adding this here and still having it defined in the service? https://github.com/symfony/webpack-encore-bundle/blob/main/src/Resources/config/services.xml#L29-L35

Can we have just this one (and remove the service config)? And if so, will it work even though there is no service with the id TagRenderer::class?

}
}