diff --git a/src/DI/Compiler.php b/src/DI/Compiler.php index df410f7d6..4549d6093 100644 --- a/src/DI/Compiler.php +++ b/src/DI/Compiler.php @@ -211,7 +211,9 @@ public function processExtensions() /** @internal */ public function processServices() { - $this->parseServices($this->builder, $this->config); + if (isset($this->config['services'])) { + self::addDefinitions($this->builder, $this->config['services']); + } } @@ -245,12 +247,11 @@ public function generateCode() /** - * Parses section 'services' from (unexpanded) configuration file. + * Adds service definitions from configuration. * @return void */ - public static function parseServices(ContainerBuilder $builder, array $config, $namespace = NULL) + public static function addDefinitions(ContainerBuilder $builder, array $services, $namespace = NULL) { - $services = isset($config['services']) ? $config['services'] : []; $depths = []; foreach ($services as $name => $def) { $path = []; @@ -304,7 +305,7 @@ public static function parseServices(ContainerBuilder $builder, array $config, $ } try { - static::parseService($definition, $def); + static::addDefinition($definition, $def); } catch (\Exception $e) { throw new ServiceCreationException("Service '$name': " . $e->getMessage(), 0, $e); } @@ -313,10 +314,10 @@ public static function parseServices(ContainerBuilder $builder, array $config, $ /** - * Parses single service from configuration file. + * Parses single service definition from configuration. * @return void */ - public static function parseService(ServiceDefinition $definition, $config) + public static function addDefinition(ServiceDefinition $definition, $config) { if ($config === NULL) { return; @@ -433,12 +434,24 @@ public static function parseService(ServiceDefinition $definition, $config) } - /** - * Use Helpers::filterArguments() - */ + /** @deprecated */ public static function filterArguments(array $args) { return Helpers::filterArguments($args); } + + /** @deprecated */ + public static function parseServices(ContainerBuilder $builder, array $config, $namespace = NULL) + { + self::addDefinitions($builder, $config, $namespace); + } + + + /** @deprecated */ + public static function parseService(ServiceDefinition $definition, $config) + { + self::addDefinition($definition, $config); + } + }