8000 pass project dir into the assets install command · symfony/symfony@ea57298 · GitHub
[go: up one dir, main page]

Skip to content

Commit ea57298

Browse files
committed
pass project dir into the assets install command
1 parent 5c2cee5 commit ea57298

File tree

5 files changed

+20
-3
lines changed

5 files changed

+20
-3
lines changed

UPGRADE-4.3.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ Config
55
------
66

77
* Deprecated using environment variables with `cannotBeEmpty()` if the value is validated with `validate()`
8+
9+
FrameworkBundle
10+
---------------
11+
12+
* Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will
13+
be mandatory in 5.0.

UPGRADE-5.0.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ Form
127127
FrameworkBundle
128128
---------------
129129

130+
* The project dir argument of the constructor of `AssetsInstallCommand` is required.
131+
130132
* Removed support for `bundle:controller:action` syntax to reference controllers. Use `serviceOrFqcn::method`
131133
instead where `serviceOrFqcn` is either the service ID when using controllers as services or the FQCN of the controller.
132134

src/Symfony/Bundle/FrameworkBundle/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ CHANGELOG
44
4.3.0
55
-----
66

7+
* Not passing the project directory to the constructor of the `AssetsInstallCommand` is deprecated. This argument will
8+
be mandatory in 5.0.
79
* Added `ControllerTrait::isFormValid()`
810

911
4.2.0

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,18 @@ class AssetsInstallCommand extends Command
4242
protected static $defaultName = 'assets:install';
4343

4444
private $filesystem;
45+
private $projectDirectory;
4546

46-
public function __construct(Filesystem $filesystem)
47+
public function __construct(Filesystem $filesystem, string $projectDirectory = null)
4748
{
4849
parent::__construct();
4950

51+
if (null === $projectDirectory) {
52+
@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);
53+
}
54+
5055
$this->filesystem = $filesystem;
56+
$this->projectDirectory = $projectDirectory;
5157
}
5258

5359
/**
@@ -260,11 +266,11 @@ private function getPublicDirectory(ContainerInterface $container)
260266
{
261267
$defaultPublicDir = 'public';
262268

263-
if (!$container->hasParameter('kernel.project_dir')) {
269+
if (null === $this->projectDirectory && !$container->hasParameter('kernel.project_dir')) {
264270
return $defaultPublicDir;
265271
}
266272

267-
$composerFilePath = $container->getParameter('kernel.project_dir').'/composer.json';
273+
$composerFilePath = ($this->projectDirectory ?? $container->getParameter('kernel.project_dir')).'/composer.json';
268274

269275
if (!file_exists($composerFilePath)) {
270276
return $defaultPublicDir;

src/Symfony/Bundle/FrameworkBundle/Resources/config/console.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<service id="console.command.assets_install" class="Symfony\Bundle\FrameworkBundle\Command\AssetsInstallCommand">
2121
<argument type="service" id="filesystem" />
22+
<argument>%kernel.project_dir%</argument>
2223
<tag name="console.command" command="assets:install" />
2324
</service>
2425

0 commit comments

Comments
 (0)
0