diff --git a/src/Symfony/Component/DependencyInjection/CHANGELOG.md b/src/Symfony/Component/DependencyInjection/CHANGELOG.md index e57d856fe693c..7e03a508561de 100644 --- a/src/Symfony/Component/DependencyInjection/CHANGELOG.md +++ b/src/Symfony/Component/DependencyInjection/CHANGELOG.md @@ -22,8 +22,7 @@ CHANGELOG * added "iterator" argument type for lazy iteration over a set of values and services * added "closure-proxy" argument type for turning services' methods into lazy callables * added file-wide configurable defaults for service attributes "public", "tags", - "autowire" and "inherit-tags" - * added "inherit-tags" service attribute to control tags' inheritance from parent context + "autowire" and "autoconfigure" * made the "class" attribute optional, using the "id" as fallback * using the `PhpDumper` with an uncompiled `ContainerBuilder` is deprecated and will not be supported anymore in 4.0 diff --git a/src/Symfony/Component/DependencyInjection/ChildDefinition.php b/src/Symfony/Component/DependencyInjection/ChildDefinition.php index d202170e373b2..dd02f860677f8 100644 --- a/src/Symfony/Component/DependencyInjection/ChildDefinition.php +++ b/src/Symfony/Component/DependencyInjection/ChildDefinition.php @@ -23,7 +23,6 @@ class ChildDefinition extends Definition { private $parent; - private $inheritTags = false; /** * @param string $parent The id of Definition instance to decorate @@ -57,30 +56,6 @@ public function setParent($parent) return $this; } - /** - * Sets whether tags should be inherited from the parent or not. - * - * @param bool $boolean - * - * @return $this - */ - public function setInheritTags($boolean) - { - $this->inheritTags = (bool) $boolean; - - return $this; - } - - /** - * Returns whether tags should be inherited from the parent or not. - * - * @return bool - */ - public function getInheritTags() - { - return $this->inheritTags; - } - /** * Gets an argument to pass to the service constructor/factory method. * diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php index 3936df509a0e9..036e91233c01a 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php @@ -43,7 +43,6 @@ public function __construct() 100 => array( $resolveClassPass = new ResolveClassPass(), new ResolveInstanceofConditionalsPass(), - new ResolveTagsInheritancePass(), ), ); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php index 6ec07672567d6..a2e62f4e536a5 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php @@ -77,7 +77,7 @@ private function processDefinition(ContainerBuilder $container, $id, Definition foreach ($instanceofDefs as $key => $instanceofDef) { /** @var ChildDefinition $instanceofDef */ $instanceofDef = clone $instanceofDef; - $instanceofDef->setAbstract(true)->setInheritTags(false)->setParent($parent ?: 'abstract.instanceof.'.$id); + $instanceofDef->setAbstract(true)->setParent($parent ?: 'abstract.instanceof.'.$id); $parent = 'instanceof.'.$interface.'.'.$key.'.'.$id; $container->setDefinition($parent, $instanceofDef); $instanceofTags[] = $instanceofDef->getTags(); diff --git a/src/Symfony/Component/DependencyInjection/Compiler/ResolveTagsInheritancePass.php b/src/Symfony/Component/DependencyInjection/Compiler/ResolveTagsInheritancePass.php deleted file mode 100644 index f95e6bbd533ae..0000000000000 --- a/src/Symfony/Component/DependencyInjection/Compiler/ResolveTagsInheritancePass.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\DependencyInjection\Compiler; - -use Symfony\Component\DependencyInjection\ChildDefinition; -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Exception\RuntimeException; - -/** - * Applies tags inheritance to definitions. - * - * @author Nicolas Grekas
- */
-class ResolveTagsInheritancePass extends AbstractRecursivePass
-{
- private $abstractInheritedParents = array();
-
- /**
- * {@inheritdoc}
- */
- public function process(ContainerBuilder $container)
- {
- try {
- parent::process($container);
-
- foreach ($this->abstractInheritedParents as $id) {
- $container->findDefinition($id)->setTags(array());
- }
- } finally {
- $this->abstractInheritedParents = array();
- }
- }
-
- /**
- * {@inheritdoc}
- */
- protected function processValue($value, $isRoot = false)
- {
- if (!$value instanceof ChildDefinition || !$value->getInheritTags()) {
- return parent::processValue($value, $isRoot);
- }
- $value->setInheritTags(false);
-
- if (!$this->container->has($parent = $value->getParent())) {
- throw new RuntimeException(sprintf('Parent definition "%s" does not exist.', $parent));
- }
-
- $parentDef = $this->container->findDefinition($parent);
- if ($parentDef->isAbstract()) {
- $this->abstractInheritedParents[$parent] = $parent;
- }
-
- if ($parentDef instanceof ChildDefinition) {
- $this->processValue($parentDef);
- }
-
- foreach ($parentDef->getTags() as $k => $v) {
- foreach ($v as $v) {
- $value->addTag($k, $v);
- }
- }
-
- return parent::processValue($value, $isRoot);
- }
-}
diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
index 5948201f02012..79a0b1213d4ce 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
@@ -178,9 +178,6 @@ private function getServiceDefaults(\DOMDocument $xml, $file)
if ($defaultsNode->hasAttribute('public')) {
$defaults['public'] = XmlUtils::phpize($defaultsNode->getAttribute('public'));
}
- if ($defaultsNode->hasAttribute('inherit-tags')) {
- $defaults['inherit-tags'] = XmlUtils::phpize($defaultsNode->getAttribute('inherit-tags'));
- }
if ($defaultsNode->hasAttribute('autoconfigure')) {
$defaults['autoconfigure'] = XmlUtils::phpize($defaultsNode->getAttribute('autoconfigure'));
}
@@ -225,13 +222,6 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults =
}
$definition = new ChildDefinition($parent);
-
- if ($value = $service->getAttribute('inherit-tags')) {
- $definition->setInheritTags(XmlUtils::phpize($value));
- } elseif (isset($defaults['inherit-tags'])) {
- $definition->setInheritTags($defaults['inherit-tags']);
- }
- $defaults = array();
} else {
$definition = new Definition();
@@ -318,13 +308,7 @@ private function parseDefinition(\DOMElement $service, $file, array $defaults =
$tags = $this->getChildren($service, 'tag');
- if (empty($defaults['tags'])) {
- // no-op
- } elseif (!$value = $service->getAttribute('inherit-tags')) {
- if (!$tags) {
- $tags = $defaults['tags'];
- }
- } elseif (XmlUtils::phpize($value)) {
+ if (!empty($defaults['tags'])) {
$tags = array_merge($tags, $defaults['tags']);
}
diff --git a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
index ecac79367c279..e4b2a1ba6fe39 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
+++ b/src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
@@ -51,7 +51,6 @@ class YamlFileLoader extends FileLoader
'configurator' => 'configurator',
'calls' => 'calls',
'tags' => 'tags',
- 'inherit_tags' => 'inherit_tags',
'decorates' => 'decorates',
'decoration_inner_name' => 'decoration_inner_name',
'decoration_priority' => 'decoration_priority',
@@ -74,7 +73,6 @@ class YamlFileLoader extends FileLoader
'configurator' => 'configurator',
'calls' => 'calls',
'tags' => 'tags',
- 'inherit_tags' => 'inherit_tags',
'autowire' => 'autowire',
'autoconfigure' => 'autoconfigure',
);
@@ -93,7 +91,6 @@ class YamlFileLoader extends FileLoader
private static $defaultsKeywords = array(
'public' => 'public',
'tags' => 'tags',
- 'inherit_tags' => 'inherit_tags',
'autowire' => 'autowire',
'autoconfigure' => 'autoconfigure',
);
@@ -365,12 +362,6 @@ private function parseDefinition($id, $service, $file, array $defaults)
}
$definition = new ChildDefinition($service['parent']);
-
- $inheritTag = isset($service['inherit_tags']) ? $service['inherit_tags'] : (isset($defaults['inherit_tags']) ? $defaults['inherit_tags'] : null);
- if (null !== $inheritTag) {
- $definition->setInheritTags($inheritTag);
- }
- $defaults = array();
} else {
$definition = new Definition();
@@ -458,13 +449,7 @@ private function parseDefinition($id, $service, $file, array $defaults)
throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s" in %s. Check your YAML syntax.', $id, $file));
}
- if (!isset($defaults['tags'])) {
- // no-op
- } elseif (!isset($service['inherit_tags'])) {
- if (!isset($service['tags'])) {
- $tags = $defaults['tags'];
- }
- } elseif ($service['inherit_tags']) {
+ if (isset($defaults['tags'])) {
$tags = array_merge($tags, $defaults['tags']);
}
diff --git a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
index c659694ffaa39..43ea65a2d8577 100644
--- a/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
+++ b/src/Symfony/Component/DependencyInjection/Loader/schema/dic/services/services-1.0.xsd
@@ -103,7 +103,6 @@