diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php b/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php index f41574d3b58da..b7ce65f030345 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/asset_mapper.php @@ -75,6 +75,7 @@ param('kernel.project_dir'), abstract_arg('array of excluded path patterns'), abstract_arg('exclude dot files'), + param('kernel.debug'), ]) ->set('asset_mapper.public_assets_path_resolver', PublicAssetsPathResolver::class) diff --git a/src/Symfony/Component/AssetMapper/AssetMapperRepository.php b/src/Symfony/Component/AssetMapper/AssetMapperRepository.php index b001c49bead9e..9371b32d843d4 100644 --- a/src/Symfony/Component/AssetMapper/AssetMapperRepository.php +++ b/src/Symfony/Component/AssetMapper/AssetMapperRepository.php @@ -34,6 +34,7 @@ public function __construct( private readonly string $projectRootDir, private readonly array $excludedPathPatterns = [], private readonly bool $excludeDotFiles = true, + private readonly bool $debug = false ) { } @@ -147,7 +148,7 @@ private function getDirectories(): array $this->absolutePaths = []; foreach ($this->paths as $path => $namespace) { if ($filesystem->isAbsolutePath($path)) { - if (!file_exists($path)) { + if (!file_exists($path) && $this->debug) { throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path)); } $this->absolutePaths[realpath($path)] = $namespace; @@ -161,7 +162,9 @@ private function getDirectories(): array continue; } - throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path)); + if ($this->debug) { + throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path)); + } } return $this->absolutePaths;