Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit adcd643

Browse filesBrowse files
committed
minor #32452 [Bundles] Rename getPublicPath() as getPublicDir() (javiereguiluz)
This PR was squashed before being merged into the 4.4 branch (closes #32452). Discussion ---------- [Bundles] Rename getPublicPath() as getPublicDir() | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | - | License | MIT | Doc PR | I'll add this if approved While documenting #31975 (see symfony/symfony-docs#11930) I realized that the `getPublicPath()` method name is not consistent with the rest of Symfony. In Symfony, "path" is usually associated to routes and we use "dir" for things similar to this: * `getCacheDir()` and `getLogdir()` to override Symfony structure (https://symfony.com/doc/current/configuration/override_dir_structure.html) * `binDir`, `configDir`, `srcDir`, `varDir`, `publicDir` in Symfony Flex recipes (https://github.com/symfony/recipes) to override the dir structure So, this PR proposes to rename `getPublicPath()` as `getPublicDir()` Commits ------- 4ab2f99 [Bundles] Rename getPublicPath() as getPublicDir()
2 parents c4568d1 + 4ab2f99 commit adcd643
Copy full SHA for adcd643

File tree

Expand file treeCollapse file tree

4 files changed

+9
-9
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+9
-9
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
137137
$validAssetDirs = [];
138138
/** @var BundleInterface $bundle */
139139
foreach ($kernel->getBundles() as $bundle) {
140-
if (!method_exists($bundle, 'getPublicPath')) {
141-
@trigger_error('Not defining "getPublicPath()" method is deprecated since Symfony 4.4 and will not be supported in 5.0.', E_USER_DEPRECATED);
142-
$publicPath = 'Resources/public';
140+
if (!method_exists($bundle, 'getPublicDir')) {
141+
@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);
142+
$publicDir = 'Resources/public';
143143
} else {
144-
$publicPath = $bundle->getPublicPath();
144+
$publicDir = ltrim($bundle->getPublicDir(), '\\/');
145145
}
146-
if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicPath)) {
146+
if (!is_dir($originDir = $bundle->getPath().\DIRECTORY_SEPARATOR.$publicDir)) {
147147
continue;
148148
}
149149

‎src/Symfony/Component/HttpKernel/Bundle/Bundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/Bundle.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function registerCommands(Application $application)
135135
{
136136
}
137137

138-
public function getPublicPath(): string
138+
public function getPublicDir(): string
139139
{
140140
return 'Resources/public';
141141
}

‎src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*
2121
* @author Fabien Potencier <fabien@symfony.com>
2222
*
23-
* @method string getPublicPath() Returns relative path for public assets
23+
* @method string getPublicDir() Returns relative path for the public assets directory
2424
*/
2525
interface BundleInterface extends ContainerAwareInterface
2626
{

‎src/Symfony/Component/HttpKernel/Tests/KernelTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/KernelTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ protected function getBundle($dir = null, $parent = null, $className = null, $bu
627627
{
628628
$bundle = $this
629629
->getMockBuilder('Symfony\Component\HttpKernel\Bundle\BundleInterface')
630-
->setMethods(['getPath', 'getPublicPath', 'getParent', 'getName'])
630+
->setMethods(['getPath', 'getPublicDir', 'getParent', 'getName'])
631631
->disableOriginalConstructor()
632632
;
633633

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

652652
$bundle
653653
->expects($this->any())
654-
->method('getPublicPath')
654+
->method('getPublicDir')
655655
->willReturn('Resources/public')
656656
;
657657

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.