Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6298e69

Browse filesBrowse files
committed
bug #23378 [FrameworkBundle] Do not remove files from assets dir (1ed)
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
2 parents fa6b45b + 6ed9c8d commit 6298e69
Copy full SHA for 6298e69

File tree

1 file changed

+6
-7
lines changed
Filter options

1 file changed

+6
-7
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+6-7Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.