Skip to content

Commit dcec167

Browse files
committed
bug #71 Autowire defaultBuild argument when it is not disabled (larzuk91)
This PR was merged into the master branch. Discussion ---------- Autowire defaultBuild argument when it is not disabled Closes #70 Commits ------- 6dd09de Autowire defaultBuild argument when it is not disabled
2 parents f0f4244 + 6dd09de commit dcec167

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/DependencyInjection/WebpackEncoreExtension.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ public function load(array $configs, ContainerBuilder $container)
3939
if (false !== $config['output_path']) {
4040
$factories['_default'] = $this->entrypointFactory($container, '_default', $config['output_path'], $config['cache'], $config['strict_mode']);
4141
$cacheKeys['_default'] = $config['output_path'].'/'.self::ENTRYPOINTS_FILE_NAME;
42+
43+
$container->getDefinition('webpack_encore.entrypoint_lookup_collection')
44+
->setArgument(1, '_default');
4245
}
4346

4447
foreach ($config['builds'] as $name => $path) {

tests/IntegrationTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,19 @@ public function testPreload()
163163
$response = $kernel->handle($request);
164164
$this->assertContains('</build/file1.js>; rel="preload"; as="script"', $response->headers->get('Link'));
165165
}
166+
167+
public function testAutowireDefaultBuildArgument()
168+
{
169+
$kernel = new WebpackEncoreIntegrationTestKernel(true);
170+
$kernel->boot();
171+
$container = $kernel->getContainer();
172+
173+
$container->get('public.webpack_encore.entrypoint_lookup_collection')
174+
->getEntrypointLookup();
175+
176+
// Testing that it doesn't throw an exception is enough
177+
$this->assertTrue(true);
178+
}
166179
}
167180

168181
class WebpackEncoreIntegrationTestKernel extends Kernel
@@ -231,6 +244,9 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
231244
$container->setAlias(new Alias('public.webpack_encore.tag_renderer', true), 'webpack_encore.tag_renderer');
232245
$container->getAlias('public.webpack_encore.tag_renderer')->setPrivate(false);
233246

247+
$container->setAlias(new Alias('public.webpack_encore.entrypoint_lookup_collection', true), 'webpack_encore.entrypoint_lookup_collection');
248+
$container->getAlias('public.webpack_encore.entrypoint_lookup_collection')->setPrivate(false);
249+
234250
// avoid logging request logs
235251
$container->register('logger', Logger::class)
236252
->setArgument(0, LogLevel::EMERGENCY);

0 commit comments

Comments
 (0)