Skip to content

Autowire defaultBuild argument when it is not disabled #71

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

Merged
merged 1 commit into from
Jul 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/DependencyInjection/WebpackEncoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ public function load(array $configs, ContainerBuilder $container)
if (false !== $config['output_path']) {
$factories['_default'] = $this->entrypointFactory($container, '_default', $config['output_path'], $config['cache'], $config['strict_mode']);
$cacheKeys['_default'] = $config['output_path'].'/'.self::ENTRYPOINTS_FILE_NAME;

$container->getDefinition('webpack_encore.entrypoint_lookup_collection')
->setArgument(1, '_default');
}

foreach ($config['builds'] as $name => $path) {
Expand Down
16 changes: 16 additions & 0 deletions tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ public function testPreload()
$response = $kernel->handle($request);
$this->assertContains('</build/file1.js>; rel="preload"; as="script"', $response->headers->get('Link'));
}

public function testAutowireDefaultBuildArgument()
{
$kernel = new WebpackEncoreIntegrationTestKernel(true);
$kernel->boot();
$container = $kernel->getContainer();

$container->get('public.webpack_encore.entrypoint_lookup_collection')
->getEntrypointLookup();

// Testing that it doesn't throw an exception is enough
$this->assertTrue(true);
}
}

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

$container->setAlias(new Alias('public.webpack_encore.entrypoint_lookup_collection', true), 'webpack_encore.entrypoint_lookup_collection');
$container->getAlias('public.webpack_encore.entrypoint_lookup_collection')->setPrivate(false);

// avoid logging request logs
$container->register('logger', Logger::class)
->setArgument(0, LogLevel::EMERGENCY);
Expand Down