From b373d4206b926c1c4375228f29a811bf8acf1f1e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 2 Jan 2019 17:21:45 +0100 Subject: [PATCH] pass project dir into the assets install command --- UPGRADE-4.3.md | 6 ++++++ UPGRADE-5.0.md | 2 ++ src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md | 2 ++ .../FrameworkBundle/Command/AssetsInstallCommand.php | 12 +++++++++--- .../FrameworkBundle/Resources/config/console.xml | 1 + 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/UPGRADE-4.3.md b/UPGRADE-4.3.md index c88642f610..d6a7f00203 100644 --- a/UPGRADE-4.3.md +++ b/UPGRADE-4.3.md @@ -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. diff --git a/UPGRADE-5.0.md b/UPGRADE-5.0.md index 7a845414bd..cf677c478a 100644 --- a/UPGRADE-5.0.md +++ b/UPGRADE-5.0.md @@ -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. diff --git a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md index b2096087bc..cc001ff618 100644 --- a/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md +++ b/src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md @@ -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 diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index 957d85bf39..8a6f7290a9 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -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; diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml index 9553d4d60d..9c5da8e177 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml @@ -19,6 +19,7 @@ + %kernel.project_dir%