Skip to content

Commit

Permalink
bug #23513 [FrameworkBundle] Set default public directory on install …
Browse files Browse the repository at this point in the history
…assets (yceruto)

This PR was squashed before being merged into the 3.3 branch (closes #23513).

Discussion
----------

[FrameworkBundle] Set default public directory on install assets

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

After symfony/flex#122 and symfony/recipes#106 the default directory to install assets is `public`.

Commits
-------

1bdfe0b [FrameworkBundle] Set default public directory on install assets
  • Loading branch information
fabpot committed Jul 17, 2017
2 parents c75d0c5 + 1bdfe0b commit 7beac82
Showing 1 changed file with 13 additions and 7 deletions.
Expand Up @@ -46,28 +46,28 @@ protected function configure()
$this
->setName('assets:install')
->setDefinition(array(
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'web'),
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'public'),
))
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
->setDescription('Installs bundles web assets under a public web directory')
->setDescription('Installs bundles web assets under a public directory')
->setHelp(<<<'EOT'
The <info>%command.name%</info> command installs bundle assets into a given
directory (e.g. the <comment>web</comment> directory).
directory (e.g. the <comment>public</comment> directory).
<info>php %command.full_name% web</info>
<info>php %command.full_name% public</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 (will fall back to hard copies when symbolic links aren't possible:
<info>php %command.full_name% web --symlink</info>
<info>php %command.full_name% public --symlink</info>
To make symlink relative, add the <info>--relative</info> option:
<info>php %command.full_name% web --symlink --relative</info>
<info>php %command.full_name% public --symlink --relative</info>
EOT
)
Expand All @@ -85,7 +85,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$targetArg = $this->getContainer()->getParameter('kernel.project_dir').'/'.$targetArg;

if (!is_dir($targetArg)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
// deprecated, logic to be removed in 4.0
// this allows the commands to work out of the box with web/ and public/
if (is_dir(dirname($targetArg).'/web')) {
$targetArg = dirname($targetArg).'/web';
} else {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
}
}
}

Expand Down

0 comments on commit 7beac82

Please sign in to comment.