[FrameworkBundle] Do not remove files from assets dir
This commit is contained in:
parent
fa6b45bc58
commit
6ed9c8d8c5
@ -92,7 +92,9 @@ EOT
|
|||||||
$validAssetDirs = array();
|
$validAssetDirs = array();
|
||||||
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
|
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
|
||||||
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
|
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
|
||||||
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
|
$assetDir = preg_replace('/bundle$/', '', strtolower($bundle->getName()));
|
||||||
|
$targetDir = $bundlesDir.$assetDir;
|
||||||
|
$validAssetDirs[] = $assetDir;
|
||||||
|
|
||||||
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
|
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
|
||||||
|
|
||||||
@ -132,15 +134,12 @@ EOT
|
|||||||
} else {
|
} else {
|
||||||
$this->hardCopy($originDir, $targetDir);
|
$this->hardCopy($originDir, $targetDir);
|
||||||
}
|
}
|
||||||
$validAssetDirs[] = $targetDir;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the assets of the bundles that no longer exist
|
// remove the assets of the bundles that no longer exist
|
||||||
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
|
$dirsToRemove = Finder::create()->depth(0)->directories()->exclude($validAssetDirs)->in($bundlesDir);
|
||||||
if (!in_array($dir, $validAssetDirs)) {
|
$filesystem->remove($dirsToRemove);
|
||||||
$filesystem->remove($dir);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user