Skip to content

Commit

Permalink
bug #23378 [FrameworkBundle] Do not remove files from assets dir (1ed)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[FrameworkBundle] Do not remove files from assets dir

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

The patch introduced in #23195 removes files from `web/bundles` (eg. `.gitignore`) which is unintentional I think.

Commits
-------

6ed9c8d [FrameworkBundle] Do not remove files from assets dir
  • Loading branch information
fabpot committed Jul 4, 2017
2 parents fa6b45b + 6ed9c8d commit 6298e69
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
$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()));
$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));

Expand Down Expand Up @@ -132,15 +134,12 @@ 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);
}
}
$dirsToRemove = Finder::create()->depth(0)->directories()->exclude($validAssetDirs)->in($bundlesDir);
$filesystem->remove($dirsToRemove);
}

/**
Expand Down

0 comments on commit 6298e69

Please sign in to comment.