Skip to content

Commit 1f7ea09

Browse files
committed
[FrameworkBundle] Do not remove files from assets dir
1 parent a521246 commit 1f7ea09

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Command/AssetsInstallCommand.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
9292
$validAssetDirs = array();
9393
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
9494
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
95-
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
95+
$assetDir = preg_replace('/bundle$/', '', strtolower($bundle->getName()));
96+
$targetDir = $bundlesDir.$assetDir;
97+
$validAssetDirs[] = $assetDir;
9698

9799
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
98100

@@ -132,15 +134,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
132134
} else {
133135
$this->hardCopy($originDir, $targetDir);
134136
}
135-
$validAssetDirs[] = $targetDir;
136137
}
137138
}
139+
138140
// 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);
142-
}
143-
}
141+
$dirsToRemove = Finder::create()->depth(0)->directories()->exclude($validAssetDirs)->in($bundlesDir);
142+
$filesystem->remove($dirsToRemove);
144143
}
145144

146145
/**

0 commit comments

Comments
 (0)