Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
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
19 changes: 17 additions & 2 deletions src/Sylius/Bundle/ThemeBundle/Command/AssetsInstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configure(): void
$this
->setName('sylius:theme:assets:install')
->setDefinition([
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory', 'web'),
new InputArgument('target', InputArgument::OPTIONAL, 'The target directory'),
])
->addOption('symlink', null, InputOption::VALUE_NONE, 'Symlinks the assets instead of copying it')
->addOption('relative', null, InputOption::VALUE_NONE, 'Make relative symlinks')
Expand Down Expand Up @@ -65,7 +65,22 @@ protected function execute(InputInterface $input, OutputInterface $output): void
$symlinkMask = max($symlinkMask, AssetsInstallerInterface::RELATIVE_SYMLINK);
}

$assetsInstaller->installAssets($input->getArgument('target'), $symlinkMask);
$assetsInstaller->installAssets($this->getTargetDir($input), $symlinkMask);
}


/**
* @return string
*/
private function getTargetDir(InputInterface $input): string
{
$targetDir = $this->getContainer()->getParameter('sylius_core.public_dir');

if ($input->hasArgument('target')) {
$targetDir = $input->getArgument('target');
}

return $targetDir;
Copy link
Contributor

Choose a reason for hiding this comment

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

What would you say for something like

if ($input->hasArgument('target')) {
    return $input->getArgument('target');
}

return $this->getContainer()->getParameter('sylius_core.public_dir');

?

It cleaner, we don't set an unnecessary variable and don't call the container if there is no need.

Btw, I think we don't need these @return string docblocks for new/refactored code (we have return types).

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd say we can improve that in another PR. These redundant phpdocs are removed automatically by our CS tool, so there's no need to change it now.

}

private function getHelpMessage(): string
Expand Down