feature #29840 [FrameworkBundle] pass project dir into the assets install command (xabbuh)
This PR was merged into the 4.3-dev branch.
Discussion
----------
[FrameworkBundle] pass project dir into the assets install command
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | yes
| Tests pass? | yes
| Fixed tickets | https://github.com/symfony/symfony/pull/29708#discussion_r244287106
| License | MIT
| Doc PR |
Commits
-------
b373d4206b
pass project dir into the assets install command
This commit is contained in:
commit
34365ec2fe
@ -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.
|
||||
|
@ -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.
|
||||
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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>
|
||||
|
||||
|
Reference in New Issue
Block a user