public function testCreateWithDispatcher() { $config = new Config(); $dispatcher = new EventDispatcher(); $context = new Context(null, $config, null, $dispatcher); $this->assertSame($dispatcher, $context->getEventDispatcher()); }
/** * Starts the service container. */ public function start() { if ($this->started) { throw new LogicException('Puli is already started'); } if (null !== $this->rootDir) { $this->context = $this->createProjectContext($this->rootDir, $this->env); $bootstrapFile = $this->context->getConfig()->get(Config::BOOTSTRAP_FILE); // Run the project's bootstrap file to enable project-specific // autoloading if (null !== $bootstrapFile) { // Backup autoload functions of the PHAR $autoloadFunctions = spl_autoload_functions(); foreach ($autoloadFunctions as $autoloadFunction) { spl_autoload_unregister($autoloadFunction); } // Add project-specific autoload functions require_once Path::makeAbsolute($bootstrapFile, $this->rootDir); // Prepend autoload functions of the PHAR again // This is needed if the user specific autoload functions were // added with $prepend=true (as done by Composer) // Classes in the PHAR should always take precedence for ($i = count($autoloadFunctions) - 1; $i >= 0; --$i) { spl_autoload_register($autoloadFunctions[$i], true, true); } } } else { $this->context = $this->createGlobalContext(); } $this->dispatcher = $this->context->getEventDispatcher(); $this->started = true; // Start plugins once the container is running if ($this->rootDir && $this->pluginsEnabled) { $this->activatePlugins(); } }
/** * Starts the service container. */ public function start() { if ($this->started) { throw new LogicException('Puli is already started'); } if ($this->rootDir) { $this->context = $this->createProjectContext($this->rootDir, $this->env); $bootstrapFile = $this->context->getConfig()->get(Config::BOOTSTRAP_FILE); // Run the project's bootstrap file to enable project-specific // autoloading if (null !== $bootstrapFile) { require_once Path::makeAbsolute($bootstrapFile, $this->rootDir); } } else { $this->context = $this->createGlobalContext(); } $this->dispatcher = $this->context->getEventDispatcher(); $this->started = true; // Start plugins once the container is running if ($this->rootDir && $this->pluginsEnabled) { $this->activatePlugins(); } }