public function initialize() { $pages = $this->container->configuration->get('administration_pages', []); foreach ($pages as $name => $class) { $this->pages->set($name, new $class()); } }
/** * @param array $configuration * * @throws MissingRequiredParameter */ public function configure(array $configuration) { foreach ($this->requiredParameters as $parameter) { if (!isset($configuration[$parameter])) { throw new MissingRequiredParameter(sprintf('Required parameter "%s" should be passed to service "%s"', $parameter, self::class)); } $this->configuration->set($parameter, $configuration[$parameter]); } }
/** * @param $name * * @return mixed * * @throws \Exception */ public function get($name) { if (!$this->services->get($name)) { throw new \Exception(sprintf('Service "%s" is undefined', $name)); } if (!is_object($this->services->get($name))) { $class = $this->services->get($name); try { $configuration = $this->configuration->get($name, []); $this->replaceConfigurationParameters($configuration); $instance = $this->createServiceInstance($class, $configuration); } catch (NotInstanceOfServiceException $e) { throw new \Exception(sprintf('Service "%s" should be instance of "%s", instance of "%s" given', $name, Service::class, $class)); } $this->services->set($name, $instance); } return $this->services->get($name); }