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 9ca264c

Browse filesBrowse files
committed
[HttpKernel] removed bundle inheritance
1 parent c1d8833 commit 9ca264c
Copy full SHA for 9ca264c

File tree

Expand file treeCollapse file tree

12 files changed

+40
-230
lines changed
Filter options
Expand file treeCollapse file tree

12 files changed

+40
-230
lines changed

‎src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Controller/ControllerNameParser.php
+7-17Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,40 +54,30 @@ public function parse($controller)
5454
$originalController = $controller;
5555
list($bundle, $controller, $action) = $parts;
5656
$controller = str_replace('/', '\\', $controller);
57-
$bundles = array();
5857

5958
try {
6059
// this throws an exception if there is no such bundle
61-
$allBundles = $this->kernel->getBundle($bundle, false, true);
60+
$bundle = $this->kernel->getBundle($bundleName);
6261
} catch (\InvalidArgumentException $e) {
6362
$message = sprintf(
6463
'The "%s" (from the _controller value "%s") does not exist or is not enabled in your kernel!',
65-
$bundle,
64+
$bundleName,
6665
$originalController
6766
);
6867

69-
if ($alternative = $this->findAlternative($bundle)) {
68+
if ($alternative = $this->findAlternative($bundleName)) {
7069
$message .= sprintf(' Did you mean "%s:%s:%s"?', $alternative, $controller, $action);
7170
}
7271

7372
throw new \InvalidArgumentException($message, 0, $e);
7473
}
7574

76-
foreach ($allBundles as $b) {
77-
$try = $b->getNamespace().'\\Controller\\'.$controller.'Controller';
78-
if (class_exists($try)) {
79-
return $try.'::'.$action.'Action';
80-
}
81-
82-
$bundles[] = $b->getName();
83-
$msg = sprintf('The _controller value "%s:%s:%s" maps to a "%s" class, but this class was not found. Create this class or check the spelling of the class and its namespace.', $bundle, $controller, $action, $try);
84-
}
85-
86-
if (count($bundles) > 1) {
87-
$msg = sprintf('Unable to find controller "%s:%s" in bundles %s.', $bundle, $controller, implode(', ', $bundles));
75+
$try = $bundle->getNamespace().'\\Controller\\'.$controller.'Controller';
76+
if (class_exists($try)) {
77+
return $try.'::'.$action.'Action';
8878
}
8979

90-
throw new \InvalidArgumentException($msg);
80+
throw new \InvalidArgumentException(sprintf('The _controller value "%s:%s:%s" maps to a "%s" class, but this class was not found. Create this class or check the spelling of the class and its namespace.', $bundleName, $controller, $action, $try));
9181
}
9282

9383
/**

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ public function testValidationPaths()
604604

605605
$container = $this->createContainerFromFile('validation_annotations', array(
606606
'kernel.bundles' => array('TestBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\TestBundle'),
607-
'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/TestBundle')),
607+
'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle')),
608608
));
609609

610610
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
@@ -640,7 +640,7 @@ public function testValidationPathsUsingCustomBundlePath()
640640

641641
$container = $this->createContainerFromFile('validation_annotations', array(
642642
'kernel.bundles' => array('CustomPathBundle' => 'Symfony\\Bundle\\FrameworkBundle\\Tests\\CustomPathBundle'),
643-
'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'parent' => null, 'path' => __DIR__.'/Fixtures/CustomPathBundle')),
643+
'kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/CustomPathBundle')),
644644
));
645645

646646
$calls = $container->getDefinition('validator.builder')->getMethodCalls();
@@ -832,7 +832,7 @@ public function testSerializerCacheDisabled()
832832

833833
public function testSerializerMapping()
834834
{
835-
$container = $this->createContainerFromFile('serializer_mapping', array('kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle', 'parent' => null))));
835+
$container = $this->createContainerFromFile('serializer_mapping', array('kernel.bundles_metadata' => array('TestBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle\\Tests', 'path' => __DIR__.'/Fixtures/TestBundle'))));
836836
$configDir = __DIR__.'/Fixtures/TestBundle/Resources/config';
837837
$expectedLoaders = array(
838838
new Definition(AnnotationLoader::class, array(new Reference('annotation_reader'))),
@@ -963,7 +963,7 @@ protected function createContainer(array $data = array())
963963
{
964964
return new ContainerBuilder(new ParameterBag(array_merge(array(
965965
'kernel.bundles' => array('FrameworkBundle' => 'Symfony\\Bundle\\FrameworkBundle\\FrameworkBundle'),
966-
'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..', 'parent' => null)),
966+
'kernel.bundles_metadata' => array('FrameworkBundle' => array('namespace' => 'Symfony\\Bundle\\FrameworkBundle', 'path' => __DIR__.'/../..')),
967967
'kernel.cache_dir' => __DIR__,
968968
'kernel.project_dir' => __DIR__,
969969
'kernel.debug' => false,

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
+5-48Lines changed: 5 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,9 @@ public function load(array $configs, ContainerBuilder $container)
109109
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $config['paths']);
110110
$container->getDefinition('twig.template_iterator')->replaceArgument(2, $config['paths']);
111111

112-
$bundleHierarchy = $this->getBundleHierarchy($container, $config);
113-
114-
foreach ($bundleHierarchy as $name => $bundle) {
112+
foreach ($this->getBundleHierarchy($container, $config) as $name => $paths) {
115113
$namespace = $this->normalizeBundleName($name);
116-
117-
foreach ($bundle['children'] as $child) {
118-
foreach ($bundleHierarchy[$child]['paths'] as $path) {
119-
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
120-
}
121-
}
122-
123-
foreach ($bundle['paths'] as $path) {
114+
foreach ($paths as $path) {
124115
$twigFilesystemLoaderDefinition->addMethodCall('addPath', array($path, $namespace));
125116
}
126117
}
@@ -169,55 +160,21 @@ public function load(array $configs, ContainerBuilder $container)
169160
private function getBundleHierarchy(ContainerBuilder $container, array $config)
170161
{
171162
$bundleHierarchy = array();
172-
173163
foreach ($container->getParameter('kernel.bundles_metadata') as $name => $bundle) {
174-
if (!array_key_exists($name, $bundleHierarchy)) {
175-
$bundleHierarchy[$name] = array(
176-
'paths' => array(),
177-
'parents' => array(),
178-
'children' => array(),
179-
);
180-
}
181-
182164
if (file_exists($dir = $container->getParameter('kernel.root_dir').'/Resources/'.$name.'/views')) {
183-
$bundleHierarchy[$name]['paths'][] = $dir;
165+
$bundleHierarchy[$name][] = $dir;
184166
}
185167
$container->addResource(new FileExistenceResource($dir));
186168

187169
if (file_exists($dir = $container->getParameterBag()->resolveValue($config['default_path']).'/bundles/'.$name)) {
188-
$bundleHierarchy[$name]['paths'][] = $dir;
170+
$bundleHierarchy[$name][] = $dir;
189171
}
190172
$container->addResource(new FileExistenceResource($dir));
191173

192174
if (file_exists($dir = $bundle['path'].'/Resources/views')) {
193-
$bundleHierarchy[$name]['paths'][] = $dir;
175+
$bundleHierarchy[$name][] = $dir;
194176
}
195177
$container->addResource(new FileExistenceResource($dir));
196-
197-
if (null === $bundle['parent']) {
198-
continue;
199-
}
200-
201-
$bundleHierarchy[$name]['parents'][] = $bundle['parent'];
202-
203-
if (!array_key_exists($bundle['parent'], $bundleHierarchy)) {
204-
$bundleHierarchy[$bundle['parent']] = array(
205-
'paths' => array(),
206-
'parents' => array(),
207-
'children' => array(),
208-
);
209-
}
210-
211-
$bundleHierarchy[$bundle['parent']]['children'] = array_merge($bundleHierarchy[$name]['children'], array($name), $bundleHierarchy[$bundle['parent']]['children']);
212-
213-
foreach ($bundleHierarchy[$bundle['parent']]['parents'] as $parent) {
214-
$bundleHierarchy[$name]['parents'][] = $parent;
215-
$bundleHierarchy[$parent]['children'] = array_merge($bundleHierarchy[$name]['children'], array($name), $bundleHierarchy[$parent]['children']);
216-
}
217-
218-
foreach ($bundleHierarchy[$name]['children'] as $child) {
219-
$bundleHierarchy[$child]['parents'] = array_merge($bundleHierarchy[$child]['parents'], $bundleHierarchy[$name]['parents']);
220-
}
221178
}
222179

223180
return $bundleHierarchy;

‎src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views/layout.html.twig
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views/layout.html.twig
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildChildTwigBundle/Resources/views/layout.html.twig
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Fixtures/Bundle/ChildTwigBundle/Resources/views/layout.html.twig
-1Lines changed: 0 additions & 1 deletion
This file was deleted.

‎src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/TwigExtensionTest.php
-39Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -188,23 +188,9 @@ public function testTwigLoaderPaths($format)
188188
array('namespaced_path1', 'namespace1'),
189189
array('namespaced_path2', 'namespace2'),
190190
array('namespaced_path3', 'namespace3'),
191-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildChildTwig'),
192-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'),
193-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildChildTwig'),
194-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'Twig'),
195-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'Twig'),
196-
array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'Twig'),
197-
array(__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'Twig'),
198191
array(__DIR__.'/Fixtures/Resources/TwigBundle/views', 'Twig'),
199192
array(__DIR__.'/Fixtures/templates/bundles/TwigBundle', 'Twig'),
200193
array(realpath(__DIR__.'/../..').'/Resources/views', 'Twig'),
201-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
202-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildTwig'),
203-
array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildTwig'),
204-
array(__DIR__.'/Fixtures/Bundle/ChildTwigBundle/Resources/views', 'ChildTwig'),
205-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'),
206-
array(__DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle/Resources/views', 'ChildChildTwig'),
207-
array(__DIR__.'/Fixtures/Bundle/ChildChildTwigBundle/Resources/views', 'ChildChildTwig'),
208194
array(__DIR__.'/Fixtures/Resources/views'),
209195
array(__DIR__.'/Fixtures/templates'),
210196
), $paths);
@@ -284,37 +270,12 @@ private function createContainer()
284270
'kernel.debug' => false,
285271
'kernel.bundles' => array(
286272
'TwigBundle' => 'Symfony\\Bundle\\TwigBundle\\TwigBundle',
287-
'ChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle',
288-
'ChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle',
289-
'ChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle',
290-
'ChildChildChildChildTwigBundle' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle',
291273
),
292274
'kernel.bundles_metadata' => array(
293-
'ChildChildChildChildTwigBundle' => array(
294-
'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildChildTwigBundle\\ChildChildChildChildTwigBundle',
295-
'parent' => 'ChildChildChildTwigBundle',
296-
'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildChildTwigBundle',
297-
),
298275
'TwigBundle' => array(
299276
'namespace' => 'Symfony\\Bundle\\TwigBundle',
300-
'parent' => null,
301277
'path' => realpath(__DIR__.'/../..'),
302278
),
303-
'ChildTwigBundle' => array(
304-
'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildTwigBundle\\ChildTwigBundle',
305-
'parent' => 'TwigBundle',
306-
'path' => __DIR__.'/Fixtures/Bundle/ChildTwigBundle',
307-
),
308-
'ChildChildChildTwigBundle' => array(
309-
'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildChildTwigBundle\\ChildChildChildTwigBundle',
310-
'parent' => 'ChildChildTwigBundle',
311-
'path' => __DIR__.'/Fixtures/Bundle/ChildChildChildTwigBundle',
312-
),
313-
'ChildChildTwigBundle' => array(
314-
'namespace' => 'Symfony\\Bundle\\TwigBundle\\Tests\\DependencyInjection\\Fixtures\\Bundle\\ChildChildTwigBundle\\ChildChildTwigBundle',
315-
'parent' => 'ChildTwigBundle',
316-
'path' => __DIR__.'/Fixtures/Bundle/ChildChildTwigBundle',
317-
),
318279
),
319280
)));
320281

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/Bundle.php
-9Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,6 @@ public function getPath()
128128
return $this->path;
129129
}
130130

131-
/**
132-
* Returns the bundle parent name.
133-
*
134-
* @return string|null The Bundle parent name it overrides or null if no parent
135-
*/
136-
public function getParent()
137-
{
138-
}
139-
140131
/**
141132
* Returns the bundle name (the class short name).
142133
*

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Bundle/BundleInterface.php
-13Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ public function build(ContainerBuilder $container);
4848
*/
4949
public function getContainerExtension();
5050

51-
/**
52-
* Returns the bundle name that this bundle overrides.
53-
*
54-
* Despite its name, this method does not imply any parent/child relationship
55-
* between the bundles, just a way to extend and override an existing
56-
* bundle.
57-
*
58-
* @return string The Bundle name it overrides or null if no parent
59-
*
60-
* @deprecated This method is deprecated as of 3.4 and will be removed in 4.0.
61-
*/
62-
public function getParent();
63-
6451
/**
6552
* Returns the bundle name (the class short name).
6653
*

0 commit comments

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