Skip to content

[Bundles] Rename getPublicPath() as getPublicDir() #32452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
$validAssetDirs = [];
/** @var BundleInterface $bundle */
foreach ($kernel->getBundles() as $bundle) {
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';
if (!method_exists($bundle, 'getPublicDir')) {
@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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

\get_class, as reported by fabbot

$publicDir = 'Resources/public';
} 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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Bundle/Bundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function registerCommands(Application $application)
{
}

public function getPublicPath(): string
public function getPublicDir(): string
{
return 'Resources/public';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
* @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
{
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/HttpKernel/Tests/KernelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
{
$bundle = $this
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName'])
->setMethods(['getPath', 'getPublicDir', 'getParent', 'getName'])
->disableOriginalConstructor()
;

Expand All @@ -651,7 +651,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu

$bundle
->expects($this->any())
->method('getPublicPath')
->method('getPublicDir')
->willReturn('Resources/public')
;

Expand Down