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
-------
c16fcc93e2
Dynamic bundle assets
This commit is contained in:
commit
de710f6640
@ -137,7 +137,13 @@ EOT
|
||||
$validAssetDirs = [];
|
||||
/** @var BundleInterface $bundle */
|
||||
foreach ($kernel->getBundles() as $bundle) {
|
||||
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
|
||||
if (!method_exists($bundle, 'getPublicPath')) {
|
||||
@trigger_error('Not defining "getPublicPath()" method is deprecated since Symfony 4.4 and will not be supported in 5.0.', E_USER_DEPRECATED);
|
||||
$publicPath = 'Resources/public';
|
||||
} else {
|
||||
$publicPath = $bundle->getPublicPath();
|
||||
}
|
||||
if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicPath)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,11 @@ abstract class Bundle implements BundleInterface
|
||||
{
|
||||
}
|
||||
|
||||
public function getPublicPath(): string
|
||||
{
|
||||
return 'Resources/public';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bundle's container extension class.
|
||||
*
|
||||
|
@ -19,6 +19,8 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
|
||||
* BundleInterface.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* @method string getPublicPath() Returns relative path for public assets
|
||||
*/
|
||||
interface BundleInterface extends ContainerAwareInterface
|
||||
{
|
||||
|
@ -627,7 +627,7 @@ EOF;
|
||||
{
|
||||
$bundle = $this
|
||||
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
|
||||
->setMethods(['getPath', 'getParent', 'getName'])
|
||||
->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName'])
|
||||
->disableOriginalConstructor()
|
||||
;
|
||||
|
||||
@ -649,6 +649,12 @@ EOF;
|
||||
->willReturn($dir)
|
||||
;
|
||||
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getPublicPath')
|
||||
->willReturn('Resources/public')
|
||||
;
|
||||
|
||||
$bundle
|
||||
->expects($this->any())
|
||||
->method('getParent')
|
||||
|
Reference in New Issue
Block a user