- if (null !== $definition = $this->parseDefinition($service, $file)) {
- $this->container->setDefinition((string) $service->getAttribute('id'), $definition);
+ if (null !== $definition = $this->parseDefinition($service, $file, $defaults)) {
+ if ('prototype' === $service->tagName) {
+ $this->registerClasses($definition, (string) $service->getAttribute('namespace'), (string) $service->getAttribute('resource'), (string) $service->getAttribute('exclude'));
+ } else {
+ $this->setDefinition((string) $service->getAttribute('id'), $definition);
+ }
+ }
+ }
+ }
+
+ /**
+ * Get service defaults.
+ *
+ * @return array
+ */
+ private function getServiceDefaults(\DOMDocument $xml, $file)
+ {
+ $xpath = new \DOMXPath($xml);
+ $xpath->registerNamespace('container', self::NS);
+
+ if (null === $defaultsNode = $xpath->query('//container:services/container:defaults')->item(0)) {
+ return array();
+ }
+ $defaults = array(
+ 'tags' => $this->getChildren($defaultsNode, 'tag'),
+ 'bind' => array_map(function ($v) { return new BoundArgument($v); }, $this->getArgumentsAsPhp($defaultsNode, 'bind', $file)),
+ );
+
+ foreach ($defaults['tags'] as $tag) {
+ if ('' === $tag->getAttribute('name')) {
+ throw new InvalidArgumentException(sprintf('The tag name for tag "<defaults>" in %s must be a non-empty string.', $file));