/** * @param array $arguments * * @return array */ private function resolveArguments(array $arguments) { return array_map(function ($argument) { if ($argument === Configurator::container()) { return $this->container; } if ($this->container->has($argument)) { return $this->container->get($argument); } return $argument; }, $arguments); }
/** * @param array $arguments * * @return array */ private function resolveArguments(array $arguments) { return array_map(function ($argument) { if (!is_string($argument)) { return $argument; } if ($argument === Configurator::container()) { return $this->container; } if (isset($this->container[$argument])) { return $this->container[$argument]; } return $argument; }, $arguments); }
public function testTheContainerIdentifierStringIsAlwaysTheSame() { assertSame(Configurator::container(), Configurator::container()); }
public function testItInjectsTheContainerAsFactoryDependency() { $config = ['class_name' => ExampleClassWithArgs::class, 'di' => ['services' => ['example_service' => ['factory' => ExampleFactory::class, 'arguments' => ['config.class_name', Configurator::container()]]]]]; Configurator::apply()->configFromArray($config)->to($this->container); $instance = $this->container->get('example_service'); assertSame([$this->container], $instance->getConstructorArgs()); }