/** * {@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); } }
/** * 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; }
/** * 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; }
/** * 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; }
private function activatePlugins() { foreach ($this->context->getRootModuleFile()->getPluginClasses() as $pluginClass) { $this->validatePluginClass($pluginClass); /** @var PuliPlugin $plugin */ $plugin = new $pluginClass(); $plugin->activate($this); } }