diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php index 5d20431c95dc..18efeb3d9751 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php @@ -137,7 +137,13 @@ protected function execute(InputInterface $input, OutputInterface $output) $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; } diff --git a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php index 26dea9b20519..c3c1babe4d19 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/Bundle.php +++ b/src/Symfony/Component/HttpKernel/Bundle/Bundle.php @@ -135,6 +135,11 @@ public function registerCommands(Application $application) { } + public function getPublicPath(): string + { + return 'Resources/public'; + } + /** * Returns the bundle's container extension class. * diff --git a/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php b/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php index 88a95d833294..8dfba0a24457 100644 --- a/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php +++ b/src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php @@ -19,6 +19,8 @@ * BundleInterface. * * @author Fabien Potencier + * + * @method string getPublicPath() Returns relative path for public assets */ interface BundleInterface extends ContainerAwareInterface { diff --git a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php index f97074e1cdd0..845e8ceb0a07 100644 --- a/src/Symfony/Component/HttpKernel/Tests/KernelTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/KernelTest.php @@ -627,7 +627,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu { $bundle = $this ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') - ->setMethods(['getPath', 'getParent', 'getName']) + ->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName']) ->disableOriginalConstructor() ; @@ -649,6 +649,12 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu ->willReturn($dir) ; + $bundle + ->expects($this->any()) + ->method('getPublicPath') + ->willReturn('Resources/public') + ; + $bundle ->expects($this->any()) ->method('getParent')