[Bundles] Rename getPublicPath() as getPublicDir()

This commit is contained in:
Javier Eguiluz 2019-07-09 10:08:52 +02:00 committed by Fabien Potencier
parent ac7938b116
commit 4ab2f9955b
4 changed files with 9 additions and 9 deletions

View File

@ -137,13 +137,13 @@ EOT
$validAssetDirs = []; $validAssetDirs = [];
/** @var BundleInterface $bundle */ /** @var BundleInterface $bundle */
foreach ($kernel->getBundles() as $bundle) { foreach ($kernel->getBundles() as $bundle) {
if (!method_exists($bundle, 'getPublicPath')) { if (!method_exists($bundle, 'getPublicDir')) {
@trigger_error('Not defining "getPublicPath()" method is deprecated since Symfony 4.4 and will not be supported in 5.0.', E_USER_DEPRECATED); @trigger_error(sprintf('Not defining "getPublicDir()" method in the "%s" class is deprecated since Symfony 4.4 and will not be supported in 5.0.', get_class($bundle)), E_USER_DEPRECATED);
$publicPath = 'Resources/public'; $publicDir = 'Resources/public';
} else { } else {
$publicPath = $bundle->getPublicPath(); $publicDir = ltrim($bundle->getPublicDir(), '\\/');
} }
if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicPath)) { if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicDir)) {
continue; continue;
} }

View File

@ -135,7 +135,7 @@ abstract class Bundle implements BundleInterface
{ {
} }
public function getPublicPath(): string public function getPublicDir(): string
{ {
return 'Resources/public'; return 'Resources/public';
} }

View File

@ -20,7 +20,7 @@ use Symfony\Component\DependencyInjection\Extension\ExtensionInterface;
* *
* @author Fabien Potencier <fabien@symfony.com> * @author Fabien Potencier <fabien@symfony.com>
* *
* @method string getPublicPath() Returns relative path for public assets * @method string getPublicDir() Returns relative path for the public assets directory
*/ */
interface BundleInterface extends ContainerAwareInterface interface BundleInterface extends ContainerAwareInterface
{ {

View File

@ -627,7 +627,7 @@ EOF;
{ {
$bundle = $this $bundle = $this
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface') ->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName']) ->setMethods(['getPath', 'getPublicDir', 'getParent', 'getName'])
->disableOriginalConstructor() ->disableOriginalConstructor()
; ;
@ -651,7 +651,7 @@ EOF;
$bundle $bundle
->expects($this->any()) ->expects($this->any())
->method('getPublicPath') ->method('getPublicDir')
->willReturn('Resources/public') ->willReturn('Resources/public')
; ;