Skip to content

Commit 256353e

Browse files
committed
Simplified strictMode handling. EntrypointLookupCollection::getEntrypointLookup fails because build is not configured but not because file doesn't exist.
1 parent ce7e615 commit 256353e

File tree

6 files changed

+5
-35
lines changed

6 files changed

+5
-35
lines changed

src/Asset/EmptyEntrypointLookup.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/Asset/EntrypointLookupCollection.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,23 @@ class EntrypointLookupCollection implements EntrypointLookupCollectionInterface
2727

2828
private $strictMode;
2929

30-
public function __construct(ContainerInterface $buildEntrypoints, string $defaultBuildName = null, bool $strictMode = true)
30+
public function __construct(ContainerInterface $buildEntrypoints, string $defaultBuildName = null)
3131
{
3232
$this->buildEntrypoints = $buildEntrypoints;
3333
$this->defaultBuildName = $defaultBuildName;
34-
$this->strictMode = $strictMode;
3534
}
3635

3736
public function getEntrypointLookup(string $buildName = null): EntrypointLookupInterface
3837
{
3938
if (null === $buildName) {
4039
if (null === $this->defaultBuildName) {
41-
if (!$this->strictMode) return new EmptyEntrypointLookup();
4240
throw new UndefinedBuildException('There is no default build configured: please pass an argument to getEntrypointLookup().');
4341
}
4442

4543
$buildName = $this->defaultBuildName;
4644
}
4745

4846
if (!$this->buildEntrypoints->has($buildName)) {
49-
if (!$this->strictMode) return new EmptyEntrypointLookup();
5047
throw new UndefinedBuildException(sprintf('The build "%s" is not configured', $buildName));
5148
}
5249

src/DependencyInjection/WebpackEncoreExtension.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,7 @@ public function load(array $configs, ContainerBuilder $container)
4949
->replaceArgument(0, $cacheKeys);
5050

5151
$container->getDefinition('webpack_encore.entrypoint_lookup_collection')
52-
->replaceArgument(0, ServiceLocatorTagPass::register($container, $factories))
53-
->replaceArgument(2, $config['strict_mode']);
54-
55-
$container->getDefinition('webpack_encore.twig_entry_files_extension')
56-
->replaceArgument(1, $config['strict_mode']);
52+
->replaceArgument(0, ServiceLocatorTagPass::register($container, $factories));
5753

5854
$container->setAlias(EntrypointLookupInterface::class, new Alias($this->getEntrypointServiceId('_default')));
5955
}

src/Resources/config/services.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
<service id="webpack_encore.entrypoint_lookup_collection" class="Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection">
1111
<argument /> <!-- build list of entrypoints locator -->
12-
<argument /> <!-- defaultBuildName -->
13-
<argument /> <!-- strictMode -->
1412
</service>
1513

1614
<service id="Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollectionInterface" alias="webpack_encore.entrypoint_lookup_collection" />
@@ -31,7 +29,6 @@
3129
</argument>
3230
</service>
3331
</argument>
34-
<argument /><!-- strict mode -->
3532
</service>
3633

3734
<service id="webpack_encore.entrypoint_lookup.cache_warmer" class="Symfony\WebpackEncoreBundle\CacheWarmer\EntrypointCacheWarmer">

src/Twig/EntryFilesTwigExtension.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,10 @@
1818
final class EntryFilesTwigExtension extends AbstractExtension
1919
{
2020
private $container;
21-
private $strictMode;
2221

23-
public function __construct(ContainerInterface $container, bool $strictMode)
22+
public function __construct(ContainerInterface $container)
2423
{
2524
$this->container = $container;
26-
$this->strictMode = $strictMode;
2725
}
2826

2927
public function getFunctions()

tests/IntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testEnabledStrictMode_throwsException_ifBuildMissing()
107107
{
108108
$kernel = new WebpackEncoreIntegrationTestKernel(true);
109109
$kernel->outputPath = 'missing_build';
110-
$kernel->builds = [];
110+
$kernel->builds = ['different_build' => 'missing_build'];
111111
$kernel->boot();
112112
$container = $kernel->getContainer();
113113

@@ -119,7 +119,7 @@ public function testDisabledStrictMode_ignoresMissingBuild()
119119
$kernel = new WebpackEncoreIntegrationTestKernel(true);
120120
$kernel->outputPath = 'missing_build';
121121
$kernel->strictMode = false;
122-
$kernel->builds = [];
122+
$kernel->builds = ['different_build' => 'missing_build'];
123123
$kernel->boot();
124124
$container = $kernel->getContainer();
125125

0 commit comments

Comments
 (0)