Example #1
0
 /**
  * Checks if the definition is valid.
  *
  * @param ContainerBuilder $container  The container.
  * @param Definition       $definition The definition.
  * @param string           $id         The identifier.
  * @param array            $tag        The tag data.
  *
  * @throws DefinitionException If the definition is not valid.
  */
 protected function validate(ContainerBuilder $container, Definition $definition, $id, array $tag)
 {
     if ($definition->isAbstract()) {
         throw DefinitionException::taggedServiceAbstract($id, $this->tag);
         // @codeCoverageIgnore
     }
     if (!$definition->isPublic()) {
         throw DefinitionException::taggedServiceNotPublic($id, $this->tag);
         // @codeCoverageIgnore
     }
     if (null !== $this->parent) {
         $reflection = new ReflectionClass($container->getParameterBag()->resolveValue($definition->getClass()));
         // @codeCoverageIgnoreStart
         if (!$reflection->isSubclassOf($this->parent)) {
             throw DefinitionException::taggedServiceNotSubclass($id, $this->tag, $this->parent);
         }
         // @codeCoverageIgnoreEnd
     }
 }