/** * Adds new configuration from file. * @return self */ public function loadConfig(string $file) : self { $loader = new Config\Loader(); $this->addConfig($loader->load($file)); $this->addDependencies($loader->getDependencies()); return $this; }
/** * Reads configuration from file. * @param string file name * @return array */ public function loadFromFile($file) { $loader = new Config\Loader(); $res = $loader->load($file); $this->compiler->addDependencies($loader->getDependencies()); return $res; }
/** * Adds new configuration from file. * @return self */ public function loadConfig($file) { $loader = new Config\Loader(); $this->addConfig($loader->load($file)); $this->dependencies->add($loader->getDependencies()); return $this; }
/** * Reads configuration from file. * @param string file name * @return array */ public function loadFromFile($file) { $loader = new Config\Loader(); $res = $loader->load($file); $container = $this->compiler->getContainerBuilder(); foreach ($loader->getDependencies() as $file) { $container->addDependency($file); } return $res; }
/** * Adds configuration file. * @return self */ public function addConfig($file, $section = NULL) { if ($section === NULL && $this->parameters['debugMode']) { // back compatibility try { $loader = new DI\Config\Loader(); $loader->load($file, $this->parameters['environment']); trigger_error("Config file '{$file}' has sections, call addConfig() with second parameter Configurator::AUTO.", E_USER_WARNING); $section = $this->parameters['environment']; } catch (\Exception $e) { } } $this->files[] = array($file, $section === self::AUTO ? $this->parameters['environment'] : $section); return $this; }
/** * @param Compiler $compiler * @return string */ public function generateContainer(Compiler $compiler) { // Load configs $loader = new Loader(); $compiler->addConfig(['parameters' => $this->parameters]); foreach ($this->configs as $config) { $compiler->addConfig($loader->load($config)); } $compiler->addDependencies($loader->getDependencies()); // Exclude classes $builder = $compiler->getContainerBuilder(); $builder->addExcludedClasses($this->excludedClasses); // Fire events foreach ($this->onCompile as $cb) { call_user_func_array($cb, [$compiler]); } // Compile container $classes = $compiler->compile(); $classes[0]->setExtends(PiDiContainer::class); return implode("\n", []) . "\n\n" . implode("\n\n\n", $classes); }