pass project dir into the assets install command

This commit is contained in:
Christian Flothmann 2019-01-02 17:21:45 +01:00
parent 5c2cee5c0f
commit b373d4206b
5 changed files with 20 additions and 3 deletions

View File

@ -5,3 +5,9 @@ Config
------
* Deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
FrameworkBundle
---------------
* Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will
be mandatory in 5.0.

View File

@ -127,6 +127,8 @@ Form
FrameworkBundle
---------------
* The project dir argument of the constructor of `AssetsInstallCommand` is required.
* Removed support for `bundle:controller:action` syntax to reference controllers. Use `serviceOrFqcn::method`
instead where `serviceOrFqcn` is either the service ID when using controllers as services or the FQCN of the controller.

View File

@ -4,6 +4,8 @@ CHANGELOG
4.3.0
-----
* Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will
be mandatory in 5.0.
* Added `ControllerTrait::isFormValid()`
4.2.0

View File

@ -42,12 +42,18 @@ class AssetsInstallCommand extends Command
protected static $defaultName = 'assets:install';
private $filesystem;
private $projectDir;
public function __construct(Filesystem $filesystem)
public function __construct(Filesystem $filesystem, string $projectDir = null)
{
parent::__construct();
if (null === $projectDir) {
@trigger_error(sprintf('Not passing the project directory to the constructor of %s is deprecated since Symfony 4.3 and will not be supported in 5.0.', __CLASS__), E_USER_DEPRECATED);
}
$this->filesystem = $filesystem;
$this->projectDir = $projectDir;
}
/**
@ -260,11 +266,11 @@ EOT
{
$defaultPublicDir = 'public';
if (!$container->hasParameter('kernel.project_dir')) {
if (null === $this->projectDir && !$container->hasParameter('kernel.project_dir')) {
return $defaultPublicDir;
}
$composerFilePath = $container->getParameter('kernel.project_dir').'/composer.json';
$composerFilePath = ($this->projectDir ?? $container->getParameter('kernel.project_dir')).'/composer.json';
if (!file_exists($composerFilePath)) {
return $defaultPublicDir;

View File

@ -19,6 +19,7 @@
<service id="console.command.assets_install" class="Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand">
<argument type="service" id="filesystem" />
<argument>%kernel.project_dir%</argument>
<tag name="console.command" command="assets:install" />
</service>