|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +/* |
| 6 | + * This file is part of the Symfony WebpackEncoreBundle package. |
| 7 | + * |
| 8 | + * (c) Fabien Potencier <[email protected]> |
| 9 | + * |
| 10 | + * For the full copyright and license information, please view the LICENSE |
| 11 | + * file that was distributed with this source code. |
| 12 | + */ |
| 13 | + |
| 14 | +namespace Symfony\Component\DependencyInjection\Loader\Configurator; |
| 15 | + |
| 16 | +use Symfony\Component\Cache\Adapter\PhpArrayAdapter; |
| 17 | +use Symfony\Component\DependencyInjection\ServiceLocator; |
| 18 | +use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection; |
| 19 | +use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollectionInterface; |
| 20 | +use Symfony\WebpackEncoreBundle\Asset\TagRenderer; |
| 21 | +use Symfony\WebpackEncoreBundle\CacheWarmer\EntrypointCacheWarmer; |
| 22 | +use Symfony\WebpackEncoreBundle\EventListener\ExceptionListener; |
| 23 | +use Symfony\WebpackEncoreBundle\EventListener\PreLoadAssetsEventListener; |
| 24 | +use Symfony\WebpackEncoreBundle\EventListener\ResetAssetsEventListener; |
| 25 | +use Symfony\WebpackEncoreBundle\Twig\EntryFilesTwigExtension; |
| 26 | + |
| 27 | +return static function (ContainerConfigurator $containerConfigurator): void { |
| 28 | + $containerConfigurator->services() |
| 29 | + ->set('webpack_encore.entrypoint_lookup_collection', EntrypointLookupCollection::class) |
| 30 | + ->args([ |
| 31 | + abstract_arg('build list of entrypoints locator'), |
| 32 | + ]) |
| 33 | + |
| 34 | + ->alias(EntrypointLookupCollectionInterface::class, 'webpack_encore.entrypoint_lookup_collection') |
| 35 | + |
| 36 | + ->set('webpack_encore.tag_renderer', TagRenderer::class) |
| 37 | + ->tag('kernel.reset', ['method' => 'reset']) |
| 38 | + ->args([ |
| 39 | + service('webpack_encore.entrypoint_lookup_collection'), |
| 40 | + service('assets.packages'), |
| 41 | + [], // Default attributes |
| 42 | + [], // Default script attributes |
| 43 | + [], // Default link attributes |
| 44 | + service('event_dispatcher'), |
| 45 | + ]) |
| 46 | + |
| 47 | + ->set('webpack_encore.twig_entry_files_extension', EntryFilesTwigExtension::class) |
| 48 | + ->tag('twig.extension') |
| 49 | + ->args([ |
| 50 | + inline_service(ServiceLocator::class) |
| 51 | + ->tag('container.service_locator') |
| 52 | + ->args([ |
| 53 | + [ |
| 54 | + 'webpack_encore.entrypoint_lookup_collection' => service('webpack_encore.entrypoint_lookup_collection'), |
| 55 | + 'webpack_encore.tag_renderer' => service('webpack_encore.tag_renderer'), |
| 56 | + ], |
| 57 | + ]), |
| 58 | + ]) |
| 59 | + |
| 60 | + ->set('webpack_encore.entrypoint_lookup.cache_warmer', EntrypointCacheWarmer::class) |
| 61 | + ->tag('kernel.cache_warmer') |
| 62 | + ->args([ |
| 63 | + abstract_arg(' build list of entrypoint paths'), |
| 64 | + service('http_client')->nullOnInvalid(), |
| 65 | + '%kernel.build_dir%/webpack_encore.cache.php', |
| 66 | + ]) |
| 67 | + |
| 68 | + ->set('webpack_encore.cache', PhpArrayAdapter::class) |
| 69 | + ->factory([PhpArrayAdapter::class, 'create']) |
| 70 | + ->args([ |
| 71 | + '%kernel.build_dir%/webpack_encore.cache.php', |
| 72 | + service('cache.webpack_encore'), |
| 73 | + ]) |
| 74 | + |
| 75 | + ->set('cache.webpack_encore') |
| 76 | + ->parent('cache.system') |
| 77 | + ->tag('cache.pool') |
| 78 | + |
| 79 | + ->set('webpack_encore.exception_listener', ExceptionListener::class) |
| 80 | + ->tag('kernel.event_listener', ['event' => 'kernel.exception']) |
| 81 | + ->args([ |
| 82 | + service('webpack_encore.entrypoint_lookup_collection'), |
| 83 | + abstract_arg('build list of build names'), |
| 84 | + ]) |
| 85 | + |
| 86 | + ->set('webpack_encore.preload_assets_event_listener', PreLoadAssetsEventListener::class) |
| 87 | + ->tag('kernel.event_subscriber') |
| 88 | + ->args([ |
| 89 | + service('webpack_encore.tag_renderer'), |
| 90 | + ]) |
| 91 | + |
| 92 | + ->set(ResetAssetsEventListener::class) |
| 93 | + ->tag('kernel.event_subscriber') |
| 94 | + ->args([ |
| 95 | + service('webpack_encore.entrypoint_lookup_collection'), |
| 96 | + ]) |
| 97 | + ; |
| 98 | +}; |
0 commit comments