protected function parseDefinition($service) { if (is_string($service) && 0 === strpos($service, '@')) { return substr($service, 1); } $definition = new sfServiceDefinition($service['class']); if (isset($service['shared'])) { $definition->setShared($service['shared']); } if (isset($service['constructor'])) { $definition->setConstructor($service['constructor']); } if (isset($service['file'])) { $definition->setFile($service['file']); } if (isset($service['arguments'])) { $definition->setArguments($this->resolveServices($service['arguments'])); } if (isset($service['configurator'])) { if (is_string($service['configurator'])) { $definition->setConfigurator($service['configurator']); } else { $definition->setConfigurator(array($this->resolveServices($service['configurator'][0]), $service['configurator'][1])); } } if (isset($service['calls'])) { foreach ($service['calls'] as $call) { $definition->addMethodCall($call[0], $this->resolveServices($call[1])); } } return $definition; }
protected function parseDefinition($service, $file) { if ((string) $service['alias']) { return (string) $service['alias']; } $definition = new sfServiceDefinition((string) $service['class']); foreach (array('shared', 'constructor') as $key) { $method = 'set' . ucfirst($key); if (isset($service[$key])) { $definition->{$method}((string) $service->getAttributeAsPhp($key)); } } if ($service->file) { $definition->setFile((string) $service->file); } $definition->setArguments($service->getArgumentsAsPhp('argument')); if (isset($service->configurator)) { if (isset($service->configurator['function'])) { $definition->setConfigurator((string) $service->configurator['function']); } else { if (isset($service->configurator['service'])) { $class = new sfServiceReference((string) $service->configurator['service']); } else { $class = (string) $service->configurator['class']; } $definition->setConfigurator(array($class, (string) $service->configurator['method'])); } } foreach ($service->call as $call) { $definition->addMethodCall((string) $call['method'], $call->getArgumentsAsPhp('argument')); } return $definition; }