/** * Loads the module repository for a given project. * * @param ProjectContext $context The project context. * @param ModuleFileStorage $moduleFileStorage The module file storage. * * @throws FileNotFoundException If the install path of a module not exist. * @throws NoDirectoryException If the install path of a module points to a file. * @throws InvalidConfigException If a configuration file contains invalid configuration. * @throws NameConflictException If a module has the same name as another loaded module. */ public function __construct(ProjectContext $context, ModuleFileStorage $moduleFileStorage) { $this->context = $context; $this->rootDir = $context->getRootDirectory(); $this->rootModuleFile = $context->getRootModuleFile(); $this->moduleFileStorage = $moduleFileStorage; }
public function testCreateWithEnvironment() { $config = new Config(); $rootPackageFile = new RootPackageFile(); $context = new ProjectContext(null, __DIR__, $config, $rootPackageFile, null, null, Environment::PROD); $this->assertSame(Environment::PROD, $context->getEnvironment()); }
/** * Loads the package repository for a given project. * * @param ProjectContext $context The project context. * @param PackageFileStorage $packageFileStorage The package file storage. * * @throws FileNotFoundException If the install path of a package not exist. * @throws NoDirectoryException If the install path of a package points to a file. * @throws InvalidConfigException If a configuration file contains invalid configuration. * @throws NameConflictException If a package has the same name as another loaded package. */ public function __construct(ProjectContext $context, PackageFileStorage $packageFileStorage) { $this->context = $context; $this->rootDir = $context->getRootDirectory(); $this->rootPackageFile = $context->getRootPackageFile(); $this->packageFileStorage = $packageFileStorage; }
/** * {@inheritdoc} */ public function refreshFactoryClass($path = null, $className = null) { Assert::nullOrStringNotEmpty($path, 'The path to the generated factory file must be a non-empty string or null. Got: %s'); Assert::nullOrStringNotEmpty($className, 'The class name of the generated factory must be a non-empty string or null. Got: %s'); $path = Path::makeAbsolute($path ?: $this->config->get(Config::FACTORY_OUT_FILE), $this->rootDir); $className = $className ?: $this->config->get(Config::FACTORY_OUT_CLASS); if (!$this->config->get(Config::FACTORY_AUTO_GENERATE)) { return; } if (!file_exists($path)) { $this->generateFactoryClass($path, $className); return; } $rootModuleFile = $this->context->getRootModuleFile()->getPath(); if (!file_exists($rootModuleFile)) { return; } // Regenerate file if the configuration has changed and // auto-generation is enabled clearstatcache(true, $rootModuleFile); $lastConfigChange = filemtime($rootModuleFile); $configFile = $this->context->getConfigFile() ? $this->context->getConfigFile()->getPath() : ''; if (file_exists($configFile)) { clearstatcache(true, $configFile); $lastConfigChange = max(filemtime($configFile), $lastConfigChange); } clearstatcache(true, $path); $lastFactoryUpdate = filemtime($path); if ($lastConfigChange > $lastFactoryUpdate) { $this->generateFactoryClass($path, $className); } }
/** * {@inheritdoc} */ public function prepareInstallation(AssetMapping $mapping) { $glob = $mapping->getGlob(); $serverName = $mapping->getServerName(); $resources = $this->repo->find($glob); if ($resources->isEmpty()) { throw NotInstallableException::noResourceMatches($glob); } if (!$this->servers->contains($serverName)) { throw NotInstallableException::serverNotFound($serverName); } $server = $this->servers->get($serverName); $installerName = $server->getInstallerName(); if (!$this->installerManager->hasInstallerDescriptor($installerName)) { throw NotInstallableException::installerNotFound($installerName); } $installerDescriptor = $this->installerManager->getInstallerDescriptor($installerName); $installer = $this->loadInstaller($installerDescriptor); $rootDir = $this->context->getRootDirectory(); $params = new InstallationParams($installer, $installerDescriptor, $resources, $mapping, $server, $rootDir); $installer->validateParams($params); return $params; }
/** * Creates a tag manager. * * @param ProjectContext $context * @param EditableDiscovery $discovery * @param ModuleList $modules * @param JsonStorage $jsonStorage * @param LoggerInterface|null $logger */ public function __construct(ProjectContext $context, EditableDiscovery $discovery, ModuleList $modules, JsonStorage $jsonStorage, LoggerInterface $logger = null) { $this->context = $context; $this->discovery = $discovery; $this->modules = $modules; $this->jsonStorage = $jsonStorage; $this->rootModule = $modules->getRootModule(); $this->rootModuleFile = $context->getRootModuleFile(); $this->logger = $logger ?: new NullLogger(); }
/** * Creates a new module file manager. * * @param ProjectContext $context The project context * @param JsonStorage $jsonStorage The module file storage. */ public function __construct(ProjectContext $context, JsonStorage $jsonStorage) { $this->context = $context; $this->rootModuleFile = $context->getRootModuleFile(); $this->jsonStorage = $jsonStorage; }
private function activatePlugins() { foreach ($this->context->getRootPackageFile()->getPluginClasses() as $pluginClass) { $this->validatePluginClass($pluginClass); /** @var PuliPlugin $plugin */ $plugin = new $pluginClass(); $plugin->activate($this); } }
/** * 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; }
/** * Creates a tag manager. * * @param ProjectContext $context * @param EditableDiscovery $discovery * @param PackageCollection $packages * @param PackageFileStorage $packageFileStorage * @param LoggerInterface $logger */ public function __construct(ProjectContext $context, EditableDiscovery $discovery, PackageCollection $packages, PackageFileStorage $packageFileStorage, LoggerInterface $logger = null) { $this->context = $context; $this->discovery = $discovery; $this->packages = $packages; $this->packageFileStorage = $packageFileStorage; $this->rootPackage = $packages->getRootPackage(); $this->rootPackageFile = $context->getRootPackageFile(); $this->logger = $logger ?: new NullLogger(); }
/** * 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; }