8000 Fix exception if assets dir is missing in prod · symfony/symfony@962a044 · GitHub
[go: up one dir, main page]

Skip to content

Commit 962a044

Browse files
committed
Fix exception if assets dir is missing in prod
1 parent 6f21d07 commit 962a044

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
param('kernel.project_dir'),
7676
abstract_arg('array of excluded path patterns'),
7777
abstract_arg('exclude dot files'),
78+
param('kernel.debug'),
7879
])
7980

8081
->set('asset_mapper.public_assets_path_resolver', PublicAssetsPathResolver::class)

src/Symfony/Component/AssetMapper/AssetMapperRepository.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function __construct(
3434
private readonly string $projectRootDir,
3535
private readonly array $excludedPathPatterns = [],
3636
private readonly bool $excludeDotFiles = true,
37+
private readonly bool $debug = false
3738
) {
3839
}
3940

@@ -147,7 +148,7 @@ private function getDirectories(): array
147148
$this->absolutePaths = [];
148149
foreach ($this->paths as $path => $namespace) {
149150
if ($filesystem->isAbsolutePath($path)) {
150-
if (!file_exists($path)) {
151+
if (!file_exists($path) && $this->debug) {
151152
throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path));
152153
}
153154
$this->absolutePaths[realpath($path)] = $namespace;
@@ -161,7 +162,9 @@ private function getDirectories(): array
161162
continue;
162163
}
163164

164-
throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path));
165+
if ($this->debug) {
166+
throw new \InvalidArgumentException(sprintf('The asset mapper directory "%s" does not exist.', $path));
167+
}
165168
}
166169

167170
return $this->absolutePaths;

0 commit comments

Comments
 (0)
0