Skip to content
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
6 changes: 3 additions & 3 deletions src/DependencyInjection/WebpackEncoreExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Symfony\Component\DependencyInjection\Compiler\ServiceLocatorTagPass;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\WebLink\EventListener\AddLinkHeaderListener;
Expand All @@ -30,8 +30,8 @@ final class WebpackEncoreExtension extends Extension

public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('services.xml');
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
$loader->load('services.php');

$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
Expand Down
98 changes: 98 additions & 0 deletions src/Resources/config/services.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<?php

declare(strict_types=1);

/*
* This file is part of the Symfony WebpackEncoreBundle package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Component\DependencyInjection\Loader\Configurator;

use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollectionInterface;
use Symfony\WebpackEncoreBundle\Asset\TagRenderer;
use Symfony\WebpackEncoreBundle\CacheWarmer\EntrypointCacheWarmer;
use Symfony\WebpackEncoreBundle\EventListener\ExceptionListener;
use Symfony\WebpackEncoreBundle\EventListener\PreLoadAssetsEventListener;
use Symfony\WebpackEncoreBundle\EventListener\ResetAssetsEventListener;
use Symfony\WebpackEncoreBundle\Twig\EntryFilesTwigExtension;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->services()
->set('webpack_encore.entrypoint_lookup_collection', EntrypointLookupCollection::class)
->args([
abstract_arg('build list of entrypoints locator'),
])

->alias(EntrypointLookupCollectionInterface::class, 'webpack_encore.entrypoint_lookup_collection')

->set('webpack_encore.tag_renderer', TagRenderer::class)
->tag('kernel.reset', ['method' => 'reset'])
->args([
service('webpack_encore.entrypoint_lookup_collection'),
service('assets.packages'),
[], // Default attributes
[], // Default script attributes
[], // Default link attributes
service('event_dispatcher'),
])

->set('webpack_encore.twig_entry_files_extension', EntryFilesTwigExtension::class)
->tag('twig.extension')
->args([
inline_service(ServiceLocator::class)
->tag('container.service_locator')
->args([
[
'webpack_encore.entrypoint_lookup_collection' => service('webpack_encore.entrypoint_lookup_collection'),
'webpack_encore.tag_renderer' => service('webpack_encore.tag_renderer'),
],
]),
])

->set('webpack_encore.entrypoint_lookup.cache_warmer', EntrypointCacheWarmer::class)
->tag('kernel.cache_warmer')
->args([
abstract_arg(' build list of entrypoint paths'),
service('http_client')->nullOnInvalid(),
'%kernel.build_dir%/webpack_encore.cache.php',
])

->set('webpack_encore.cache', PhpArrayAdapter::class)
->factory([PhpArrayAdapter::class, 'create'])
->args([
'%kernel.build_dir%/webpack_encore.cache.php',
service('cache.webpack_encore'),
])

->set('cache.webpack_encore')
->parent('cache.system')
->tag('cache.pool')

->set('webpack_encore.exception_listener', ExceptionListener::class)
->tag('kernel.event_listener', ['event' => 'kernel.exception'])
->args([
service('webpack_encore.entrypoint_lookup_collection'),
abstract_arg('build list of build names'),
])

->set('webpack_encore.preload_assets_event_listener', PreLoadAssetsEventListener::class)
->tag('kernel.event_subscriber')
->args([
service('webpack_encore.tag_renderer'),
])

->set(ResetAssetsEventListener::class)
->tag('kernel.event_subscriber')
->args([
service('webpack_encore.entrypoint_lookup_collection'),
])
;
};
72 changes: 0 additions & 72 deletions src/Resources/config/services.xml

This file was deleted.

1 change: 0 additions & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,6 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
__DIR__.'/fixtures' => 'integration_test',
],
'strict_variables' => true,
'exception_controller' => null,
]);

$container->loadFromExtension('webpack_encore', [
Expand Down
Loading