Skip to content

[FrameworkBundle] Refactored assets:install command, tweaked output #13057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Simplify foreach body
  • Loading branch information
1ed committed Dec 28, 2014
commit f7f8f8542539a11b23fef0dada03f6f69ebd9dfc
51 changes: 26 additions & 25 deletions src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,41 +99,42 @@ protected function execute(InputInterface $input, OutputInterface $output)
$table = new Table($output);
Copy link
Member

Choose a reason for hiding this comment

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

using a table has a huge drawback compared to the previous output: it is not streaming the output anymore, but waiting for all bundles to be processed before rendering anything. And if any exception happens, there won't be any report about the symlinks which have already been created

$table->setHeaders(array('Source', 'Target', 'Method / Error'));

$ret = 0;
$failed = 0;
Copy link
Member

Choose a reason for hiding this comment

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

$failed looks like a name for a boolean property, and this is not the case. Naming it $exitCode would be better, or using a real boolean (and then changing the return statement to return an integer depending on this boolean)

foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));

$this->filesystem->remove($targetDir);

if ($symlink) {
try {
$relative = $this->symlink($originDir, $targetDir, $input->getOption('relative'));
$table->addRow(array(
$bundle->getNamespace(),
$targetDir,
sprintf('%s symbolic link', $relative ? 'relative' : 'absolute'),
));

continue;
} catch (IOException $e) {
// fall back to hard copy
}
}
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
continue;
}

$targetDir = $bundlesDir.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
$this->filesystem->remove($targetDir);

if ($symlink) {
try {
$this->hardCopy($originDir, $targetDir);
$table->addRow(array($bundle->getNamespace(), $targetDir, 'hard copy'));
$relative = $this->symlink($originDir, $targetDir, $input->getOption('relative'));
$table->addRow(array(
$bundle->getNamespace(),
$targetDir,
sprintf('%s symbolic link', $relative ? 'relative' : 'absolute'),
));

continue;
} catch (IOException $e) {
$table->addRow(array($bundle->getNamespace(), $targetDir, sprintf('<error>%s</error>', $e->getMessage())));
$ret = 1;
// fall back to hard copy
}
}

try {
$this->hardCopy($originDir, $targetDir);
$table->addRow(array($bundle->getNamespace(), $targetDir, 'hard copy'));
} catch (IOException $e) {
$table->addRow(array($bundle->getNamespace(), $targetDir, sprintf('<error>%s</error>', $e->getMessage())));
$failed = 1;
}
}

$table->render();

return $ret;
return $failed;
}

/**
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy