-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[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
Closed
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fcbfcd1
[FrameworkBundle] Refactored assets:install command, tweaked output
1ed f7f8f85
Simplify foreach body
1ed a4f1a0a
Remove recursion
1ed e8bd573
Make the code more explicit, simplify foreach body
1ed 90d7f06
Simplify method names displayed on the output
1ed 736ec74
Tweaked error handling
1ed 226e98f
Simplify condition
1ed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Simplify foreach body
- Loading branch information
commit f7f8f8542539a11b23fef0dada03f6f69ebd9dfc
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -99,41 +99,42 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
$table = new Table($output); | ||
$table->setHeaders(array('Source', 'Target', 'Method / Error')); | ||
|
||
$ret = 0; | ||
$failed = 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
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; | ||
} | ||
|
||
/** | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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