Skip to content

Commit

Permalink
bug #23195 [FrameworkBundle] [Command] Clean bundle directory, fixes #…
Browse files Browse the repository at this point in the history
…23177 (NicolasPion)

This PR was squashed before being merged into the 2.7 branch (closes #23195).

Discussion
----------

[FrameworkBundle] [Command] Clean bundle directory, fixes #23177

| Q             | A
| ------------- | ---
| Branch?       | 2.7 <!-- see comment below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | no
| Fixed tickets | #23177
| License       | MIT

This PR fix #23177
when running an assets:install, it will remove directorys who do not have anymore a valid Bundle

Commits
-------

180f178 [FrameworkBundle] [Command] Clean bundle directory, fixes #23177
  • Loading branch information
fabpot committed Jun 16, 2017
2 parents c8884e7 + 180f178 commit 436d5e4
Showing 1 changed file with 8 additions and 0 deletions.
Expand Up @@ -89,6 +89,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Installing assets as <comment>hard copies</comment>.');
}

$validAssetDirs = array();
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
Expand Down Expand Up @@ -131,6 +132,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
} else {
$this->hardCopy($originDir, $targetDir);
}
$validAssetDirs[] = $targetDir;
}
}
// remove the assets of the bundles that no longer exist
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
if (!in_array($dir, $validAssetDirs)) {
$filesystem->remove($dir);
}
}
}
Expand Down

0 comments on commit 436d5e4

Please sign in to comment.