Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be $this->filesystem when merging into >= 2.8.

}

/**
Expand Down