Skip to content

Commit b59b55d

Browse files
committed
AssetPipeline -> AssetMapper
1 parent a606d90 commit b59b55d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+317
-317
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsPipelineCompileCommand.php renamed to src/Symfony/Bundle/FrameworkBundle/Command/AssetsMapperCompileCommand.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Command;
1313

14-
use Symfony\Component\AssetPipeline\AssetPipeline;
14+
use Symfony\Component\AssetMapper\AssetMapper;
1515
use Symfony\Component\Console\Attribute\AsCommand;
1616
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Exception\InvalidArgumentException;
@@ -21,19 +21,19 @@
2121
use Symfony\Component\Filesystem\Filesystem;
2222

2323
/**
24-
* Compiles the assets in the pipeline to the final output directory.
24+
* Compiles the assets in the asset mapper to the final output directory.
2525
*
2626
* This command is intended to be used during deployment.
2727
*
2828
* @author Ryan Weaver <ryan@symfonycasts.com>
2929
*
3030
* @final
3131
*/
32-
#[AsCommand(name: 'assets:pipeline:compile', description: 'Compiles all pipeline assets and writes them to the final public output directory.')]
33-
class AssetsPipelineCompileCommand extends Command
32+
#[AsCommand(name: 'assets:mapper:compile', description: 'Compiles all mapped assets and writes them to the final public output directory.')]
33+
class AssetsMapperCompileCommand extends Command
3434
{
3535
public function __construct(
36-
private readonly AssetPipeline $pipeline,
36+
private readonly AssetMapper $assetMapper,
3737
private readonly Filesystem $filesystem,
3838
private readonly string $projectDir,
3939
private readonly string $publicDirName,
@@ -47,7 +47,7 @@ protected function configure(): void
4747
$this
4848
->setHelp(<<<'EOT'
4949
The <info>%command.name%</info> command compiles and dumps all the assets in
50-
the asset pipeline into the final public directory (usually <comment>public/assets</comment>).
50+
the asset mapper into the final public directory (usually <comment>public/assets</comment>).
5151
5252
This command is meant to be run during deployment.
5353
EOT
@@ -62,9 +62,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6262
throw new InvalidArgumentException(sprintf('The public directory "%s" does not exist.', $publicDir));
6363
}
6464

65-
$allAssets = $this->pipeline->allAssets();
65+
$allAssets = $this->assetMapper->allAssets();
6666

67-
$io->comment(sprintf('Compiling <info>%d</info> assets to <info>%s%s</info>', \count($allAssets), $publicDir, $this->pipeline->getPublicPrefix()));
67+
$io->comment(sprintf('Compiling <info>%d</info> assets to <info>%s%s</info>', \count($allAssets), $publicDir, $this->assetMapper->getPublicPrefix()));
6868
$manifest = [];
6969
foreach ($allAssets as $asset) {
7070
// $asset->getPublicPath() will start with a "/"
@@ -74,11 +74,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7474
$this->filesystem->mkdir($dir);
7575
}
7676

77-
$this->filesystem->dumpFile($targetPath, $this->pipeline->getContent($asset->getLogicalPath()));
77+
$this->filesystem->dumpFile($targetPath, $this->assetMapper->getContent($asset->getLogicalPath()));
7878
$manifest[$asset->getLogicalPath()] = $asset->getPublicPath();
7979
}
8080

81-
$manifestPath = $publicDir.$this->pipeline->getPublicPrefix().AssetPipeline::MANIFEST_FILE_NAME;
81+
$manifestPath = $publicDir.$this->assetMapper->getPublicPrefix().AssetMapper::MANIFEST_FILE_NAME;
8282
$this->filesystem->dumpFile($manifestPath, json_encode($manifest, \JSON_PRETTY_PRINT));
8383
$io->comment(sprintf('Manifest written to <info>%s</info>', $manifestPath));
8484

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/UnusedTagsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class UnusedTagsPass implements CompilerPassInterface
2424
private const KNOWN_TAGS = [
2525
'annotations.cached_reader',
2626
'assets.package',
27-
'asset_pipeline.compiler',
27+
'asset_mapper.compiler',
2828
'auto_alias',
2929
'cache.pool',
3030
'cache.pool.clearer',

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Psr\Log\LogLevel;
1717
use Symfony\Bundle\FullStack;
1818
use Symfony\Component\Asset\Package;
19-
use Symfony\Component\AssetPipeline\AssetPipeline;
19+
use Symfony\Component\AssetMapper\AssetMapper;
2020
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
2121
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
2222
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
@@ -162,7 +162,7 @@ public function getConfigTreeBuilder(): TreeBuilder
162162
$this->addSessionSection($rootNode);
163163
$this->addRequestSection($rootNode);
164164
$this->addAssetsSection($rootNode, $enableIfStandalone);
165-
$this->addAssetPipelineSection($rootNode, $enableIfStandalone);
165+
$this->addAssetMapperSection($rootNode, $enableIfStandalone);
166166
$this->addTranslatorSection($rootNode, $enableIfStandalone);
167167
$this->addValidationSection($rootNode, $enableIfStandalone);
168168
$this->addAnnotationsSection($rootNode, $willBeAvailable);
@@ -812,13 +812,13 @@ private function addAssetsSection(ArrayNodeDefinition $rootNode, callable $enabl
812812
;
813813
}
814814

815-
private function addAssetPipelineSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
815+
private function addAssetMapperSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone): void
816816
{
817817
$rootNode
818818
->children()
819-
->arrayNode('asset_pipeline')
819+
->arrayNode('asset_mapper')
820820
->info('Asset Pipeline configuration')
821-
->{$enableIfStandalone('symfony/asset-pipeline', AssetPipeline::class)}()
821+
->{$enableIfStandalone('symfony/asset-mapper', AssetMapper::class)}()
822822
->fixXmlConfig('path')
823823
->children()
824824
// add array node called "paths" that will be an array of strings

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
use Symfony\Bundle\FullStack;
3232
use Symfony\Bundle\MercureBundle\MercureBundle;
3333
use Symfony\Component\Asset\PackageInterface;
34-
use Symfony\Component\AssetPipeline\AssetPipeline;
34+
use Symfony\Component\AssetMapper\AssetMapper;
3535
use Symfony\Component\BrowserKit\AbstractBrowser;
3636
use Symfony\Component\Cache\Adapter\AdapterInterface;
3737
use Symfony\Component\Cache\Adapter\ArrayAdapter;
@@ -331,12 +331,12 @@ public function load(array $configs, ContainerBuilder $container)
331331
$this->registerAssetsConfiguration($config['assets'], $container, $loader);
332332
}
333333

334-
if ($this->readConfigEnabled('asset_pipeline', $container, $config['asset_pipeline'])) {
335-
if (!class_exists(AssetPipeline::class)) {
336-
throw new LogicException('AssetPipeline support cannot be enabled as the AssetPipeline component is not installed. Try running "composer require symfony/asset-pipeline".');
334+
if ($this->readConfigEnabled('asset_mapper', $container, $config['asset_mapper'])) {
335+
if (!class_exists(AssetMapper::class)) {
336+
throw new LogicException('AssetMapper support cannot be enabled as the AssetMapper component is not installed. Try running "composer require symfony/asset-mapper".');
337337
}
338338

339-
$this->registerAssetPipelineConfiguration($config['asset_pipeline'], $container, $loader, $this->readConfigEnabled('assets', $container, $config['assets']));
339+
$this->registerAssetMapperConfiguration($config['asset_mapper'], $container, $loader, $this->readConfigEnabled('assets', $container, $config['assets']));
340340
}
341341

342342
if ($this->readConfigEnabled('http_client', $container, $config['http_client'])) {
@@ -1240,18 +1240,18 @@ private function registerAssetsConfiguration(array $config, ContainerBuilder $co
12401240
}
12411241
}
12421242

1243-
private function registerAssetPipelineConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $assetEnabled): void
1243+
private function registerAssetMapperConfiguration(array $config, ContainerBuilder $container, PhpFileLoader $loader, bool $assetEnabled): void
12441244
{
1245-
$loader->load('asset_pipeline.php');
1245+
$loader->load('asset_mapper.php');
12461246

12471247
if (!$assetEnabled) {
1248-
$container->removeDefinition('asset_pipeline.asset_package');
1248+
$container->removeDefinition('asset_mapper.asset_package');
12491249

12501250
return;
12511251
}
12521252

12531253
$publicDirName = $this->getPublicDirectoryName((string) $container->getParameter('kernel.project_dir'));
1254-
$container->getDefinition('asset_pipeline')
1254+
$container->getDefinition('asset_mapper')
12551255
->setArgument(4, $config['public_prefix'])
12561256
->setArgument(5, $publicDirName)
12571257
;
@@ -1262,14 +1262,14 @@ private function registerAssetPipelineConfiguration(array $config, ContainerBuil
12621262
$paths[$dir] = sprintf('bundles/%s', preg_replace('/bundle$/', '', strtolower($name)));
12631263
}
12641264
}
1265-
$container->getDefinition('asset_pipeline_repository')
1265+
$container->getDefinition('asset_mapper_repository')
12661266
->setArgument(0, $paths);
12671267

1268-
$container->getDefinition('asset_pipeline.command.publish')
1268+
$container->getDefinition('asset_mapper.command.publish')
12691269
->setArgument(3, $publicDirName);
12701270

12711271
if (!$config['server']) {
1272-
$container->removeDefinition('asset_pipeline.dev_server_subscriber');
1272+
$container->removeDefinition('asset_mapper.dev_server_subscriber');
12731273
}
12741274
}
12751275

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Symfony\Bundle\FrameworkBundle\Command\AssetsMapperCompileCommand;
15+
use Symfony\Component\AssetMapper\AssetMapper;
16+
use Symfony\Component\AssetMapper\AssetMapperCompiler;
17+
use Symfony\Component\AssetMapper\AssetMapperDevServerSubscriber;
18+
use Symfony\Component\AssetMapper\AssetMapperRepository;
19+
use Symfony\Component\AssetMapper\Compiler\CssAssetUrlCompiler;
20+
use Symfony\Component\AssetMapper\Compiler\JavaScriptImportPathCompiler;
21+
use Symfony\Component\AssetMapper\Compiler\SourceMappingUrlsCompiler;
22+
use Symfony\Component\AssetMapper\MapperAwareAssetPackage;
23+
use Symfony\Component\HttpKernel\Event\RequestEvent;
24+
25+
return static function (ContainerConfigurator $container) {
26+
$container->services()
27+
->set('asset_mapper', AssetMapper::class)
28+
->args([
29+
service('asset_mapper_repository'),
30+
service('mime_types'),
31+
service('asset_mapper_compiler'),
32+
param('kernel.project_dir'),
33+
abstract_arg('asset public prefix'),
34+
abstract_arg('public directory name'),
35+
])
36+
->set('asset_mapper_repository', AssetMapperRepository::class)
37+
->args([
38+
abstract_arg('array of asset mapper paths'),
39+
param('kernel.project_dir'),
40+
])
41+
->set('asset_mapper.asset_package', MapperAwareAssetPackage::class)
42+
->decorate('assets._default_package')
43+
->args([
44+
service('.inner'),
45+
service('asset_mapper'),
46+
])
47+
48+
->set('asset_mapper.dev_server_subscriber', AssetMapperDevServerSubscriber::class)
49+
->args([
50+
service('asset_mapper'),
51+
])
52+
->tag('kernel.event_subscriber', ['event' => RequestEvent::class])
53+
54+
->set('asset_mapper.command.publish', AssetsMapperCompileCommand::class)
55+
->args([
56+
service('asset_mapper'),
57+
service('filesystem'),
58+
param('kernel.project_dir'),
59+
abstract_arg('public directory name'),
60+
param('kernel.debug'),
61+
])
62+
->tag('console.command')
63+
64+
->set('asset_mapper_compiler', AssetMapperCompiler::class)
65+
->args([
66+
tagged_iterator('asset_mapper.compiler'),
67+
])
68+
69+
->set('asset_mapper.compiler.css_asset_url_compiler', CssAssetUrlCompiler::class)
70+
->tag('asset_mapper.compiler')
71+
72+
->set('asset_mapper.compiler.source_mapping_urls_compiler', SourceMappingUrlsCompiler::class)
73+
->tag('asset_mapper.compiler')
74+
75+
->set('asset_mapper.compiler.javascript_import_path_compiler', JavaScriptImportPathCompiler::class)
76+
->tag('asset_mapper.compiler')
77+
;
78+
};

src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_pipeline.php

Lines changed: 0 additions & 78 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\AssetsPipelineCompileCommand;
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\AssetsMapperCompileCommand;
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bundle\FrameworkBundle\Console\Application;
16-
use Symfony\Bundle\FrameworkBundle\Tests\Command\AssetsPipelineCompileCommand\Fixture\TestAppKernel;
16+
use Symfony\Bundle\FrameworkBundle\Tests\Command\AssetsMapperCompileCommand\Fixture\TestAppKernel;
1717
use Symfony\Component\Console\Tester\CommandTester;
1818
use Symfony\Component\Filesystem\Filesystem;
1919
use Symfony\Component\Finder\Finder;
2020

21-
class AssetsPipelineCompileCommandTest extends TestCase
21+
class AssetsMapperCompileCommandTest extends TestCase
2222
{
2323
private TestAppKernel $kernel;
2424
private Filesystem $filesystem;
@@ -40,7 +40,7 @@ public function testAssetsAreCompiled()
4040
{
4141
$application = new Application($this->kernel);
4242

43-
$command = $application->find('assets:pipeline:compile');
43+
$command = $application->find('assets:mapper:compile');
4444
$tester = new CommandTester($command);
4545
$res = $tester->execute([]);
4646
$this->assertSame(0, $res);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\AssetsPipelineCompileCommand\Fixture;
12+
namespace Symfony\Bundle\FrameworkBundle\Tests\Command\AssetsMapperCompileCommand\Fixture;
1313

1414
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1515
use Symfony\Component\Config\Loader\LoaderInterface;
@@ -37,7 +37,7 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
3737
$container->loadFromExtension('framework', [
3838
'http_method_override' => false,
3939
'assets' => null,
40-
'asset_pipeline' => [
40+
'asset_mapper' => [
4141
'paths' => ['dir1', 'dir2'],
4242
],
4343
'test' => true,

0 commit comments

Comments
 (0)