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 09a870a

Browse filesBrowse files
committed
remove getBundleDir method and reuse the current getPath instead
1 parent d9fdee4 commit 09a870a
Copy full SHA for 09a870a

File tree

Expand file treeCollapse file tree

16 files changed

+23
-99
lines changed
Filter options
Expand file treeCollapse file tree

16 files changed

+23
-99
lines changed

‎UPGRADE-4.4.md

Copy file name to clipboardExpand all lines: UPGRADE-4.4.md
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,6 @@ HttpFoundation
108108
HttpKernel
109109
----------
110110

111-
* Implementing the `BundleInterface` without implementing the `getBundleDir()` method is deprecated.
112-
This method will be added to the interface in 5.0.
113111
* The `DebugHandlersListener` class has been marked as `final`
114112

115113
Lock

‎UPGRADE-5.0.md

Copy file name to clipboardExpand all lines: UPGRADE-5.0.md
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ HttpFoundation
286286
HttpKernel
287287
----------
288288

289-
* The `getBundleDir()` method has been added to the `BundleInterface`.
290289
* Removed `Client`, use `HttpKernelBrowser` instead
291290
* The `Kernel::getRootDir()` and the `kernel.root_dir` parameter have been removed
292291
* The `KernelInterface::getName()` and the `kernel.name` parameter have been removed

‎src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/DoctrineValidationPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function updateValidatorMappingFiles(ContainerBuilder $container, string
5151
$validationPath = '/config/validation.'.$this->managerType.'.'.$extension;
5252

5353
foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
54-
if ($container->fileExists($file = $bundle['path'].'/Resources'.$validationPath) || (isset($bundle['dir']) && $container->fileExists($file = $bundle['dir'].$validationPath))) {
54+
if ($container->fileExists($file = $bundle['path'].'/Resources'.$validationPath) || $container->fileExists($file = $bundle['path'].$validationPath)) {
5555
$files[] = $file;
5656
}
5757
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
137137
$validAssetDirs = [];
138138
/** @var BundleInterface $bundle */
139139
foreach ($kernel->getBundles() as $bundle) {
140-
if (!is_dir($originDir = $bundle->getPath().'/Resources/public') && (!method_exists($bundle, 'getBundleDir') || !is_dir($originDir = $bundle->getBundleDir().'/public'))) {
140+
if (!is_dir($originDir = $bundle->getPath().'/Resources/public') && !is_dir($originDir = $bundle->getPath().'/public')) {
141141
continue;
142142
}
143143

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
+6-20Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
162162
if (null !== $input->getArgument('bundle')) {
163163
try {
164164
$bundle = $kernel->getBundle($input->getArgument('bundle'));
165-
$transPaths = [$bundle->getPath().'/Resources/translations'];
166-
$viewsPaths = [$bundle->getPath().'/Resources/views'];
167-
if (method_exists($bundle, 'getBundleDir')) {
168-
if (!is_dir($bundle->getPath().'/Resources/translations')) {
169-
$transPaths = [$bundle->getBundleDir().'/translations'];
170-
}
171-
if (!is_dir($bundle->getPath().'/Resources/views')) {
172-
$viewsPaths = [$bundle->getBundleDir().'/templates'];
173-
}
174-
}
165+
$bundleDir = $bundle->getPath();
166+
$transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations'];
167+
$viewsPaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates'];
175168
if ($this->defaultTransPath) {
176169
$transPaths[] = $this->defaultTransPath;
177170
}
@@ -214,16 +207,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
214207
}
215208
} elseif ($input->getOption('all')) {
216209
foreach ($kernel->getBundles() as $bundle) {
217-
if (method_exists($bundle, 'getBundleDir') && !is_dir($bundle->getPath().'/Resources/translations')) {
218-
$transPaths[] = $bundle->getBundleDir().'/translations';
219-
} else {
220-
$transPaths[] = $bundle->getPath().'/Resources/translations';
221-
}
222-
if (method_exists($bundle, 'getBundleDir') && !is_dir($bundle->getPath().'/Resources/views')) {
223-
$viewsPaths[] = $bundle->getBundleDir().'/templates';
224-
} else {
225-
$viewsPaths[] = $bundle->getPath().'/Resources/views';
226-
}
210+
$bundleDir = $bundle->getPath();
211+
$transPaths[] = is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundle->getPath().'/translations';
212+
$viewsPaths[] = is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundle->getPath().'/templates';
227213
if (is_dir($deprecatedPath = sprintf('%s/Resources/%s/translations', $rootDir, $bundle->getName()))) {
228214
$transPaths[] = $deprecatedPath;
229215
$notice = sprintf('Storing translations files for "%s" in the "%s" directory is deprecated since Symfony 4.2, ', $bundle->getName(), $deprecatedPath);

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+3-10Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
154154
if (null !== $input->getArgument('bundle')) {
155155
try {
156156
$foundBundle = $kernel->getBundle($input->getArgument('bundle'));
157-
$transPaths = [$foundBundle->getPath().'/Resources/translations'];
158-
$viewsPaths = [$foundBundle->getPath().'/Resources/views'];
159-
if (method_exists($foundBundle, 'getBundleDir')) {
160-
if (!is_dir($foundBundle->getPath().'/Resources/translations')) {
161-
$transPaths = [$foundBundle->getBundleDir().'/translations'];
162-
}
163-
if (!is_dir($foundBundle->getPath().'/Resources/views')) {
164-
$viewsPaths = [$foundBundle->getBundleDir().'/templates'];
165-
}
166-
}
157+
$bundleDir = $foundBundle->getPath();
158+
$transPaths = [is_dir($bundleDir.'/Resources/translations') ? $bundleDir.'/Resources/translations' : $bundleDir.'/translations'];
159+
$viewsPaths = [is_dir($bundleDir.'/Resources/views') ? $bundleDir.'/Resources/views' : $bundleDir.'/templates'];
167160
if ($this->defaultTransPath) {
168161
$transPaths[] = $this->defaultTransPath;
169162
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+3-11Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,7 +1152,7 @@ private function registerTranslatorConfiguration(array $config, ContainerBuilder
11521152
$defaultDir = $container->getParameterBag()->resolveValue($config['default_path']);
11531153
$rootDir = $container->getParameter('kernel.root_dir');
11541154
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
1155-
if ($container->fileExists($dir = $bundle['path'].'/Resources/translations') || (isset($bundle['dir']) && $container->fileExists($dir = $bundle['dir'].'/translations'))) {
1155+
if ($container->fileExists($dir = $bundle['path'].'/Resources/translations') || $container->fileExists($dir = $bundle['path'].'/translations')) {
11561156
$dirs[] = $dir;
11571157
} else {
11581158
$nonExistingDirs[] = $dir;
@@ -1314,11 +1314,7 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
13141314
}
13151315

13161316
foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
1317-
if (isset($bundle['dir']) && !is_dir($bundle['path'].'/Resources/config')) {
1318-
$configDir = $bundle['dir'].'/config';
1319-
} else {
1320-
$configDir = $bundle['path'].'/Resources/config';
1321-
}
1317+
$configDir = is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' : $bundle['path'].'/config';
13221318

13231319
if (
13241320
$container->fileExists($file = $configDir.'/validation.yaml', false) ||
@@ -1512,11 +1508,7 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
15121508
};
15131509

15141510
foreach ($container->getParameter('kernel.bundles_metadata') as $bundle) {
1515-
if (isset($bundle['dir']) && !is_dir($bundle['path'].'/Resources/config')) {
1516-
$configDir = $bundle['dir'].'/config';
1517-
} else {
1518-
$configDir = $bundle['path'].'/Resources/config';
1519-
}
1511+
$configDir = is_dir($bundle['path'].'/Resources/config') ? $bundle['path'].'/Resources/config' : $bundle['path'].'/config';
15201512

15211513
if ($container->fileExists($file = $configDir.'/serialization.xml', false)) {
15221514
$fileRecorder('xml', $file);

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/ModernBundle/src/ModernBundle.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/ModernBundle/src/ModernBundle.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515

1616
class ModernBundle extends Bundle
1717
{
18-
public function getBundleDir(): string
18+
public function getPath(): string
1919
{
20-
return \dirname($this->getPath());
20+
return \dirname(__DIR__);
2121
}
2222
}

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/BundlePathsTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/BundlePathsTest.php
+2-11Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,6 @@
2020

2121
class BundlePathsTest extends AbstractWebTestCase
2222
{
23-
public function testBundleDir()
24-
{
25-
static::bootKernel(['test_case' => 'BundlePaths']);
26-
$bundlesMetadata = static::$container->getParameter('kernel.bundles_metadata');
27-
28-
$this->assertSame($bundlesMetadata['LegacyBundle']['path'], $bundlesMetadata['LegacyBundle']['dir']);
29-
$this->assertSame(\dirname($bundlesMetadata['ModernBundle']['path']), $bundlesMetadata['ModernBundle']['dir']);
30-
}
31-
3223
public function testBundlePublicDir()
3324
{
3425
$kernel = static::bootKernel(['test_case' => 'BundlePaths']);
@@ -52,10 +43,10 @@ public function testBundleTwigTemplatesDir()
5243
$twig = static::$container->get('twig');
5344
$bundlesMetadata = static::$container->getParameter('kernel.bundles_metadata');
5445

55-
$this->assertSame([$bundlesMetadata['LegacyBundle']['dir'].'/Resources/views'], $twig->getLoader()->getPaths('Legacy'));
46+
$this->assertSame([$bundlesMetadata['LegacyBundle']['path'].'/Resources/views'], $twig->getLoader()->getPaths('Legacy'));
5647
$this->assertSame("OK\n", $twig->render('@Legacy/index.html.twig'));
5748

58-
$this->assertSame([$bundlesMetadata['ModernBundle']['dir'].'/templates'], $twig->getLoader()->getPaths('Modern'));
49+
$this->assertSame([$bundlesMetadata['ModernBundle']['path'].'/templates'], $twig->getLoader()->getPaths('Modern'));
5950
$this->assertSame("OK\n", $twig->render('@Modern/index.html.twig'));
6051
}
6152

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ private function getBundleTemplatePaths(ContainerBuilder $container, array $conf
188188
}
189189
$container->addResource(new FileExistenceResource($defaultOverrideBundlePath));
190190

191-
if (file_exists($dir = $bundle['path'].'/Resources/views') || (isset($bundle['dir']) && file_exists($dir = $bundle['dir'].'/templates'))) {
191+
if (file_exists($dir = $bundle['path'].'/Resources/views') || file_exists($dir = $bundle['path'].'/templates')) {
192192
$bundleHierarchy[$name][] = $dir;
193193
}
194194
$container->addResource(new FileExistenceResource($dir));

‎src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/TemplateIterator.php
+1-5Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ public function getIterator()
6565
$name = substr($name, 0, -6);
6666
}
6767

68-
if (method_exists($bundle, 'getBundleDir') && !is_dir($bundle->getPath().'/Resources/views')) {
69-
$bundleTemplatesDir = $bundle->getBundleDir().'/templates';
70-
} else {
71-
$bundleTemplatesDir = $bundle->getPath().'/Resources/views';
72-
}
68+
$bundleTemplatesDir = is_dir($bundle->getPath().'/Resources/views') ? $bundle->getPath().'/Resources/views' : $bundle->getPath().'/templates';
7369

7470
$templates = array_merge(
7571
$templates,

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/Bundle.php
-17Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ abstract class Bundle implements BundleInterface
3131
protected $extension;
3232
protected $path;
3333
private $namespace;
34-
private $dir;
3534

3635
/**
3736
* {@inheritdoc}
@@ -118,22 +117,6 @@ public function getPath()
118117
return $this->path;
119118
}
120119

121-
/**
122-
* {@inheritdoc}
123-
*/
124-
public function getBundleDir(): string
125-
{
126-
if (null === $this->dir) {
127-
$reflected = new \ReflectionObject($this);
128-
$this->dir = \dirname($reflected->getFileName());
129-
if (!file_exists($this->dir.'/composer.json') && file_exists(\dirname($this->dir).'/composer.json')) {
130-
$this->dir = \dirname($this->dir);
131-
}
132-
}
133-
134-
return $this->dir;
135-
}
136-
137120
/**
138121
* Returns the bundle name (the class short name).
139122
*

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@
1919
* BundleInterface.
2020
*
2121
* @author Fabien Potencier <fabien@symfony.com>
22-
*
23-
* @method string getBundleDir() Returns the bundle directory - not implementing it is deprecated since Symfony 4.4
2422
*/
2523
interface BundleInterface extends ContainerAwareInterface
2624
{

‎src/Symfony/Component/HttpKernel/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/CHANGELOG.md
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ CHANGELOG
44
4.4.0
55
-----
66

7-
* Implementing the `BundleInterface` without implementing the `getBundleDir()` method is deprecated.
8-
This method will be added to the interface in 5.0.
97
* The `DebugHandlersListener` class has been marked as `final`
108

119
4.3.0

‎src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/ConfigDataCollector.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ public function collect(Request $request, Response $response, \Exception $except
7878

7979
if (isset($this->kernel)) {
8080
foreach ($this->kernel->getBundles() as $name => $bundle) {
81-
$bundleDir = method_exists($bundle, 'getBundleDir') ? $bundle->getBundleDir() : $bundle->getPath();
82-
$this->data['bundles'][$name] = $this->hasVarDumper ? new LinkStub($bundleDir) : $bundleDir;
81+
$this->data['bundles'][$name] = $this->hasVarDumper ? new LinkStub($bundle->getPath()) : $bundle->getPath();
8382
}
8483

8584
$this->data['symfony_state'] = $this->determineSymfonyState();

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Kernel.php
+2-11Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public function locateResource($name, $dir = null, $first = true)
264264
$files[] = $file;
265265
}
266266

267-
if (file_exists($file = $bundle->getPath().'/'.$path) || (method_exists($bundle, 'getBundleDir') && file_exists($file = $bundle->getBundleDir().'/'.$path))) {
267+
if (file_exists($file = $bundle->getPath().'/'.$path)) {
268268
if ($first && !$isResource) {
269269
return $file;
270270
}
@@ -605,17 +605,8 @@ protected function getKernelParameters()
605605

606606
foreach ($this->bundles as $name => $bundle) {
607607
$bundles[$name] = \get_class($bundle);
608-
$bundlePath = $bundle->getPath();
609-
610-
if (method_exists($bundle, 'getBundleDir')) {
611-
$bundleDir = $bundle->getBundleDir();
612-
} else {
613-
@trigger_error(sprintf('Not defining "getBundleDir()" 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);
614-
$bundleDir = $bundlePath;
615-
}
616608
$bundlesMetadata[$name] = [
617-
'path' => $bundlePath,
618-
'dir' => $bundleDir,
609+
'path' => $bundle->getPath(),
619610
'namespace' => $bundle->getNamespace(),
620611
];
621612
}

0 commit comments

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