[FrameworkBundle] Place initialization of $bundlesDir out of foreach loop

Code enhancement. $bundlesDir variable doesnt't need any bundle information for initialization. So it must be placed out of the loop to not process unnecessary operations.
This commit is contained in:
Alex Pods 2013-05-01 10:39:32 +04:00
parent 2dc012ed01
commit 9cca065d85

View File

@ -80,13 +80,13 @@ EOT
$filesystem = $this->getContainer()->get('filesystem');
// Create the bundles directory otherwise symlink will fail.
$filesystem->mkdir($targetArg.'/bundles/', 0777);
$bundlesDir = $targetArg.'/bundles/';
$filesystem->mkdir($bundlesDir, 0777);
$output->writeln(sprintf("Installing assets using the <comment>%s</comment> option", $input->getOption('symlink') ? 'symlink' : 'hard copy'));
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
$bundlesDir = $targetArg.'/bundles/';
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));