* * 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\ContainerBuilder; use Symfony\Component\DependencyInjection\Exception\EnvParameterException; use Symfony\Component\DependencyInjection\Exception\RuntimeException; /** * This pass validates each definition individually only taking the information * into account which is contained in the definition itself. * * Later passes can rely on the following, and specifically do not need to * perform these checks themselves: * * - non synthetic, non abstract services always have a class set * - synthetic services are always public * * @author Johannes M. Schmitt */ class CheckDefinitionValidityPass implements CompilerPassInterface { /** * Processes the ContainerBuilder to validate the Definition. * * @throws RuntimeException When the Definition is invalid */ public function process(ContainerBuilder $container) { foreach ($container->getDefinitions() as $id => $definition) { // synthetic service is public if ($definition->isSynthetic() && !($definition->isPublic() || $definition->isPrivate())) { throw new RuntimeException(sprintf('A synthetic service ("%s") must be public.', $id)); } // non-synthetic, non-abstract service has class if (!$definition->isAbstract() && !$definition->isSynthetic() && !$definition->getClass()) { if ($definition->getFactory()) { throw new RuntimeException(sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); } if (class_exists($id) || interface_exists($id, false)) { throw new RuntimeException(sprintf( 'The definition for "%s" has no class attribute, and appears to reference a ' .'class or interface in the global namespace. Leaving out the "class" attribute ' .'is only allowed for namespaced classes. Please specify the class attribute ' .'explicitly to get rid of this error.', $id )); } throw new RuntimeException(sprintf( 'The definition for "%s" has no class. If you intend to inject ' .'this service dynamically at runtime, please mark it as synthetic=true. ' .'If this is an abstract definition solely used by child definitions, ' .'please add abstract=true, otherwise specify a class to get rid of this error.', $id )); } // tag attribute values must be scalars foreach ($definition->getTags() as $name => $tags) { foreach ($tags as $attributes) { foreach ($attributes as $attribute => $value) { if (!is_scalar($value) && null !== $value) { throw new RuntimeException(sprintf('A "tags" attribute must be of a scalar-type for service "%s", tag "%s", attribute "%s".', $id, $name, $attribute)); } } } } if ($definition->isPublic() && !$definition->isPrivate()) { $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); if (null !== $usedEnvs) { throw new EnvParameterException(array($resolvedId), null, 'A service name ("%s") cannot contain dynamic values.'); } } } foreach ($container->getAliases() as $id => $alias) { if ($alias->isPublic() && !$alias->isPrivate()) { $resolvedId = $container->resolveEnvPlaceholders($id, null, $usedEnvs); if (null !== $usedEnvs) { throw new EnvParameterException(array($resolvedId), null, 'An alias name ("%s") cannot contain dynamic values.'); } } } } } __halt_compiler();----SIGNATURE:----M3XmsQq+R85UJOJY7h4pKaf+/ITZYdCLLRHI+k3+VJlRnzs63t0uLPYcu+zKkUB62pMCzR7Hx7+CQmMnovr6d0BQ7b8dLNJeBYJW4tsTyheUz3sBYsD9qHAaf98PfLhvsUFTj+iEsJMvNoWYvNgsLlwmEqK940iplWcOQWmj2OgA3Eomahf1vDFLyxKIvmt2Omz/JziiSx6MqErL0H4rlaqt0w0Qe96eOisz+5e7JCnGcgGChcopHyUzNkNpd1w+Y0SyPRToJSExzBDL1mmoOFUlKOKdFNB9bKntTvSq7yrYYUazp1d4SjW0BGit6i9nMr/tcJSMwrRrDl0cZd6sqkLDGY4VUMDsvNiHo9zplokjZwbX7IPfVMU+A1MmTl3nx4OPCib4gzgGJMC/6PX9MzAFMHQykCYr6kqBklSKqQOUm29XQWZK4Bvbl5Qu7HBotv3bTdSMqExvwz3V8oIh53ZDVq/nk8Kwm/MQZOYf76ybDikiaaSSEUiF2Z1QoSKMz/Fuv4WyqI+vPzf77Su0sZvtWL5Hq9eT8OPdf/MA1B1rNZem+H0MDvZpownpsN59OptAI9VS4A3ddEVqWf0SPRrdxXNWMs2CLYaZni8MaUwVn8scF17+TorCJXKlju0ScI+UimdAK+ZobXTn7IyjURc+sBn9kslfyfsoe0aQXGc=----ATTACHMENT:----NDUzNTkwOTk4NjYxOTU0MCAzNjUyMDU1OTM0NDc4NTgyIDMzOTU3MTE0NjA2NjE3Nzk=