/** * Creates a new factory generator. * * @param ProjectContext $context The project context. * @param GeneratorRegistry $generatorRegistry The registry providing * the generators for the * services returned by the * factory. * @param ClassWriter $classWriter The writer that writes * the class to a file. * @param ServerCollection|null $servers The configured servers. */ public function __construct(ProjectContext $context, GeneratorRegistry $generatorRegistry, ClassWriter $classWriter, ServerCollection $servers = null) { $this->context = $context; $this->config = $context->getConfig(); $this->rootDir = $context->getRootDirectory(); $this->generatorRegistry = $generatorRegistry; $this->classWriter = $classWriter; $this->servers = $servers; }
public function testCreate() { $config = new Config(); $rootPackageFile = new RootPackageFile(); $context = new ProjectContext(null, __DIR__, $config, $rootPackageFile); $this->assertNull($context->getHomeDirectory()); $this->assertSame(__DIR__, $context->getRootDirectory()); $this->assertSame($config, $context->getConfig()); $this->assertSame($rootPackageFile, $context->getRootPackageFile()); $this->assertNull($context->getConfigFile()); $this->assertSame(Environment::DEV, $context->getEnvironment()); $this->assertInstanceOf('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', $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(); } }
/** * Creates a repository manager. * * @param ProjectContext $context * @param EditableRepository $repo * @param ModuleList $modules * @param JsonStorage $jsonStorage */ public function __construct(ProjectContext $context, EditableRepository $repo, ModuleList $modules, JsonStorage $jsonStorage) { $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); $this->repo = $repo; $this->config = $context->getConfig(); $this->rootDir = $context->getRootDirectory(); $this->rootModule = $modules->getRootModule(); $this->rootModuleFile = $context->getRootModuleFile(); $this->modules = $modules; $this->jsonStorage = $jsonStorage; }
/** * 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(); } }
/** * Creates a repository manager. * * @param ProjectContext $context * @param EditableRepository $repo * @param PackageCollection $packages * @param PackageFileStorage $packageFileStorage */ public function __construct(ProjectContext $context, EditableRepository $repo, PackageCollection $packages, PackageFileStorage $packageFileStorage) { $this->context = $context; $this->dispatcher = $context->getEventDispatcher(); $this->repo = $repo; $this->config = $context->getConfig(); $this->rootDir = $context->getRootDirectory(); $this->rootPackage = $packages->getRootPackage(); $this->rootPackageFile = $context->getRootPackageFile(); $this->packages = $packages; $this->packageFileStorage = $packageFileStorage; }