Skip to content

Commit 030b536

Browse 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 707a947 + a461992 commit 030b536

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

Bundle/Bundle.php

Lines 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
*

Bundle/BundleInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
* BundleInterface.
2020
*
2121
* @author Fabien Potencier <[email protected]>
22+
*
23+
* @method string getPublicPath() Returns relative path for public assets
2224
*/
2325
interface BundleInterface extends ContainerAwareInterface
2426
{

Tests/KernelTest.php

Lines 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)