Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit de710f6

Browse filesBrowse files
committed
feature #31975 Dynamic bundle assets (garak)
This PR was squashed before being merged into the 4.4 branch (closes #31975). Discussion ---------- Dynamic bundle assets | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no (new method in interface as annotation) | Deprecations? | no | Tests pass? | yes | Fixed tickets | #29213 | License | MIT | Doc PR | none (yet) Everything is explained in linked issue Commits ------- c16fcc9 Dynamic bundle assets
2 parents 4a50400 + c16fcc9 commit de710f6
Copy full SHA for de710f6

File tree

Expand file treeCollapse file tree

4 files changed

+21
-2
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+21
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
137137
$validAssetDirs = [];
138138
/** @var BundleInterface $bundle */
139139
foreach ($kernel->getBundles() as $bundle) {
140-
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
140+
if (!method_exists($bundle, 'getPublicPath')) {
141+
@trigger_error('Not defining "getPublicPath()" method is deprecated since Symfony 4.4 and will not be supported in 5.0.', E_USER_DEPRECATED);
142+
$publicPath = 'Resources/public';
143+
} else {
144+
$publicPath = $bundle->getPublicPath();
145+
}
146+
if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicPath)) {
141147
continue;
142148
}
143149

‎src/Symfony/Component/HttpKernel/Bundle/Bundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/Bundle.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ public function registerCommands(Application $application)
135135
{
136136
}
137137

138+
public function getPublicPath(): string
139+
{
140+
return 'Resources/public';
141+
}
142+
138143
/**
139144
* Returns the bundle's container extension class.
140145
*

‎src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* BundleInterface.
2020
*
2121
* @author Fabien Potencier <fabien@symfony.com>
22+
*
23+
* @method string getPublicPath() Returns relative path for public assets
2224
*/
2325
interface BundleInterface extends ContainerAwareInterface
2426
{

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
627627
{
628628
$bundle = $this
629629
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
630-
->setMethods(['getPath', 'getParent', 'getName'])
630+
->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName'])
631631
->disableOriginalConstructor()
632632
;
633633

@@ -649,6 +649,12 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
649649
->willReturn($dir)
650650
;
651651

652+
$bundle
653+
->expects($this->any())
654+
->method('getPublicPath')
655+
->willReturn('Resources/public')
656+
;
657+
652658
$bundle
653659
->expects($this->any())
654660
->method('getParent')

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.