<?php use GtfsMerger\Console\Application; use Nette\DI; use Symfony\Component\Console; require __DIR__ . '/../vendor/autoload.php'; $loader = new DI\ContainerLoader(sys_get_temp_dir(), TRUE); $class = $loader->load(time(), function (DI\Compiler $compiler) { $compiler->addExtension('php', new DI\Extensions\PhpExtension()); $compiler->loadConfig(__DIR__ . '/config.neon'); }); /** @var DI\Container $container */ $container = new $class(); $configParams = $container->getParameters(); $version = $configParams['version']; $build = $configParams['build']; $app = new Application('GTFS Merger', $version, $build); $commands = $container->findByType(Console\Command\Command::class); foreach ($commands as $command) { $app->add($container->getService($command)); } $app->run();
/** * @return Container */ public function createContainer() { // Create folder $cache = $this->cacheDir . '/PiDi'; if (!is_dir($cache)) { @mkdir($cache, 0777, TRUE); } // Parameters $this->parameters = array_merge($this->getDefaultParameters(), $this->parameters); // Build container $loader = new ContainerLoader($cache, $this->parameters['debugMode']); $class = $loader->load([$cache, $this->parameters, $this->configs, $this->excludedClasses], [$this, 'generateContainer']); // Create & initialize container $container = new $class(); $container->initialize(); return $container; }
/** * Returns system DI container. * @return DI\Container */ public function createContainer() { $loader = new DI\ContainerLoader($this->getCacheDirectory() . '/Nette.Configurator', $this->parameters['debugMode']); $class = $loader->load([$this->parameters, $this->files], [$this, 'generateContainer']); $container = new $class(); foreach ($this->services as $name => $service) { $container->addService($name, $service); } $container->initialize(); if (class_exists('Nette\\Environment')) { Nette\Environment::setContext($container); // back compatibility } return $container; }
/** * Loads system DI container class and returns its name. * @return string */ public function loadContainer() { $loader = new DI\ContainerLoader($this->getCacheDirectory() . '/Nette.Configurator', $this->parameters['debugMode']); $class = $loader->load([$this, 'generateContainer'], [$this->parameters, $this->files, PHP_VERSION_ID - PHP_RELEASE_VERSION]); return $class; }