Skip to content

Commit 2a8089a

Browse files
Nicolas Pionfabpot
authored andcommitted
[FrameworkBundle] [Command] Clean bundle directory, fixes #23177
1 parent e978ed5 commit 2a8089a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Command/AssetsInstallCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
8989
$output->writeln('Installing assets as <comment>hard copies</comment>.');
9090
}
9191

92+
$validAssetDirs = array();
9293
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
9394
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
9495
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
@@ -131,6 +132,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
131132
} else {
132133
$this->hardCopy($originDir, $targetDir);
133134
}
135+
$validAssetDirs[] = $targetDir;
136+
}
137+
}
138+
// remove the assets of the bundles that no longer exist
139+
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
140+
if (!in_array($dir, $validAssetDirs)) {
141+
$filesystem->remove($dir);
134142
}
135143
}
136144
}

0 commit comments

Comments
 (0)