/** * Saves a root module file. * * The module file is saved to the same path that it was read from. * * @param RootModuleFile $moduleFile The module file to save. * * @throws WriteException If the file cannot be written. * @throws InvalidConfigException If the file contains invalid configuration. */ public function saveRootModuleFile(RootModuleFile $moduleFile) { $this->saveFile($moduleFile, $moduleFile->getPath(), array('targetVersion' => $moduleFile->getVersion())); if ($this->factoryManager) { $this->factoryManager->autoGenerateFactoryClass(); } }
/** * Saves a configuration file. * * The configuration file is saved to the same path that it was read from. * * @param ConfigFile $configFile The configuration file to save. * * @throws IOException If the file cannot be written. */ public function saveConfigFile(ConfigFile $configFile) { $this->writer->writeConfigFile($configFile, $configFile->getPath()); if ($this->factoryManager) { $this->factoryManager->autoGenerateFactoryClass(); } }
/** * Saves a root package file. * * The package file is saved to the same path that it was read from. * * @param RootPackageFile $packageFile The package file to save. * * @throws IOException If the file cannot be written. */ public function saveRootPackageFile(RootPackageFile $packageFile) { $this->writer->writePackageFile($packageFile, $packageFile->getPath()); if ($this->factoryManager) { $this->factoryManager->autoGenerateFactoryClass(); } }
/** * Saves a root package file. * * The package file is saved to the same path that it was read from. * * @param RootPackageFile $packageFile The package file to save. * * @throws StorageException If the file cannot be written. */ public function saveRootPackageFile(RootPackageFile $packageFile) { $serialized = $this->serializer->serializeRootPackageFile($packageFile); $this->storage->write($packageFile->getPath(), $serialized); if ($this->factoryManager) { $this->factoryManager->autoGenerateFactoryClass(); } }
/** * Saves a configuration file. * * The configuration file is saved to the same path that it was read from. * * @param ConfigFile $configFile The configuration file to save. * * @throws StorageException If the file cannot be written. */ public function saveConfigFile(ConfigFile $configFile) { $serialized = $this->serializer->serializeConfigFile($configFile); $this->storage->write($configFile->getPath(), $serialized); if ($this->factoryManager) { $this->factoryManager->autoGenerateFactoryClass(); } }
/** * Handles the "build" command. * * @param Args $args The console arguments. * * @return int The status code. */ public function handle(Args $args) { $target = $args->getArgument('target'); if (!in_array($target, self::$targets)) { throw new RuntimeException(sprintf('Invalid build target "%s". Expected one of: "%s"', $target, implode('", "', self::$targets))); } if ('all' === $target || 'factory' === $target) { $this->factoryManager->autoGenerateFactoryClass(); } if ('all' === $target || 'repository' === $target) { $this->repoManager->clearRepository(); $this->repoManager->buildRepository(); } if ('all' === $target || 'discovery' === $target) { $this->discoveryManager->clearDiscovery(); $this->discoveryManager->buildDiscovery(); } return 0; }
/** * @expectedException \RuntimeException * @expectedExceptionMessage Invalid build target "foobar". Expected one of: "all", "factory", "repository", "discovery" */ public function testBuildFailsIfInvalidTarget() { $args = self::$buildCommand->parseArgs(new StringArgs('foobar')); $this->factoryManager->expects($this->never())->method('autoGenerateFactoryClass'); $this->repoManager->expects($this->never())->method('clearRepository'); $this->repoManager->expects($this->never())->method('buildRepository'); $this->discoveryManager->expects($this->never())->method('clearDiscovery'); $this->discoveryManager->expects($this->never())->method('buildDiscovery'); $this->handler->handle($args); }
/** * Saves a configuration file. * * The configuration file is saved to the same path that it was read from. * * @param ConfigFile $configFile The configuration file to save. * * @throws WriteException If the file cannot be written. * @throws InvalidConfigException If the file contains invalid configuration. */ public function saveConfigFile(ConfigFile $configFile) { try { $jsonData = $this->configFileConverter->toJson($configFile); } catch (ConversionFailedException $e) { throw new InvalidConfigException(sprintf('The data written to %s could not be converted: %s', $configFile->getPath(), $e->getMessage()), 0, $e); } $json = $this->encode($jsonData, $configFile->getPath()); $this->storage->write($configFile->getPath(), $json); if ($this->factoryManager) { $this->factoryManager->autoGenerateFactoryClass(); } }
/** * @return FactoryManager */ public function getFactoryManager() { if (!$this->started) { throw new LogicException('Puli was not started'); } if (!$this->factoryManager && $this->context instanceof ProjectContext) { $this->factoryManager = new FactoryManagerImpl($this->context, new DefaultGeneratorRegistry(), new ClassWriter()); // Don't set via the constructor to prevent cyclic dependencies $this->factoryManager->setPackages($this->getPackageManager()->getPackages()); $this->factoryManager->setServers($this->getServerManager()->getServers()); } return $this->factoryManager; }
/** * @return FactoryManager */ public function getFactoryManager() { if (!$this->started) { throw new LogicException('Puli was not started'); } if (!$this->factoryManager && $this->rootDir) { $this->factoryManager = new FactoryManagerImpl($this->environment, new DefaultGeneratorRegistry(), new ClassWriter()); // Don't set via the constructor to prevent a cyclic dependency $this->factoryManager->setServers($this->getServerManager()->getServers()); } return $this->factoryManager; }