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