Merge remote branch 'weaverryan/assets_install_command_mods'

* weaverryan/assets_install_command_mods:
  [FrameworkBundle] Improving the output and help messages in the task (no behavioral change)
This commit is contained in:
Fabien Potencier 2011-04-11 18:37:00 +02:00
commit 78c5a0ac90

View File

@ -18,7 +18,7 @@ use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\Output; use Symfony\Component\Console\Output\Output;
/** /**
* AssetsInstallCommand. * Command that places bundle web assets into a given directory.
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
*/ */
@ -31,9 +31,23 @@ class AssetsInstallCommand extends Command
{ {
$this $this
->setDefinition(array( ->setDefinition(array(
new InputArgument('target', InputArgument::REQUIRED, 'The target directory'), new InputArgument('target', InputArgument::REQUIRED, 'The target directory (usually "web")'),
)) ))
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it') ->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
->setHelp(<<<EOT
The <info>assets:install</info> command installs bundle assets into a given
directory (e.g. the web directory).
<info>./app/console assets:install web [--symlink]</info>
A "bundles" directory will be created inside the target directory, and the
"Resources/public" directory of each bundle will be copied into it.
To create a symlink to each bundle instead of copying its assets, use the
<info>--symlink</info> option.
EOT
)
->setName('assets:install') ->setName('assets:install')
; ;
} }
@ -56,10 +70,10 @@ class AssetsInstallCommand extends Command
foreach ($this->container->get('kernel')->getBundles() as $bundle) { foreach ($this->container->get('kernel')->getBundles() as $bundle) {
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) { if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
$output->writeln(sprintf('Installing assets for <comment>%s</comment>', $bundle->getNamespace()));
$targetDir = $input->getArgument('target').'/bundles/'.preg_replace('/bundle$/', '', strtolower($bundle->getName())); $targetDir = $input->getArgument('target').'/bundles/'.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
$output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
$filesystem->remove($targetDir); $filesystem->remove($targetDir);
if ($input->getOption('symlink')) { if ($input->getOption('symlink')) {