getConfig() public method

Returns the configuration of the module.
public getConfig ( ) : Puli\Manager\Api\Config\Config
return Puli\Manager\Api\Config\Config The configuration.
Example #1
0
 /**
  * Creates the context of a Puli project.
  *
  * The home directory is read from the context variable "PULI_HOME".
  * If this variable is not set, the home directory defaults to:
  *
  *  * `$HOME/.puli` on Linux, where `$HOME` is the context variable
  *    "HOME".
  *  * `$APPDATA/Puli` on Windows, where `$APPDATA` is the context
  *    variable "APPDATA".
  *
  * If none of these variables can be found, an exception is thrown.
  *
  * A .htaccess file is put into the home directory to protect it from web
  * access.
  *
  * @param string $rootDir The path to the project.
  *
  * @return ProjectContext The project context.
  */
 private function createProjectContext($rootDir, $env)
 {
     Assert::fileExists($rootDir, 'Could not load Puli context: The root %s does not exist.');
     Assert::directory($rootDir, 'Could not load Puli context: The root %s is a file. Expected a directory.');
     $baseConfig = new DefaultConfig();
     $homeDir = self::parseHomeDirectory();
     if (null !== ($configFile = $this->loadConfigFile($homeDir, $baseConfig))) {
         $baseConfig = $configFile->getConfig();
     }
     // Create a storage without the factory manager
     $moduleFileStorage = new ModuleFileStorage($this->getStorage(), $this->getLegacyModuleFileConverter(), $this->getLegacyRootModuleFileConverter(), $this->getJsonEncoder(), $this->getJsonDecoder());
     $rootDir = Path::canonicalize($rootDir);
     $rootFilePath = $this->rootDir . '/puli.json';
     try {
         $rootModuleFile = $moduleFileStorage->loadRootModuleFile($rootFilePath, $baseConfig);
     } catch (FileNotFoundException $e) {
         $rootModuleFile = new RootModuleFile(null, $rootFilePath, $baseConfig);
     }
     $config = new EnvConfig($rootModuleFile->getConfig());
     return new ProjectContext($homeDir, $rootDir, $config, $rootModuleFile, $configFile, $this->dispatcher, $env);
 }
 /**
  * {@inheritdoc}
  */
 public function getConfig()
 {
     return $this->rootModuleFile->getConfig();
 }
Example #3
0
 protected function addJsonToRootModuleFile(stdClass $jsonData, RootModuleFile $moduleFile)
 {
     if (isset($jsonData->order)) {
         $moduleFile->setModuleOrder((array) $jsonData->order);
     }
     if (isset($jsonData->plugins)) {
         $moduleFile->setPluginClasses($jsonData->plugins);
     }
     if (isset($jsonData->config)) {
         $config = $moduleFile->getConfig();
         foreach ($this->objectsToArrays($jsonData->config) as $key => $value) {
             $config->set($key, $value);
         }
     }
     if (isset($jsonData->modules)) {
         foreach ($jsonData->modules as $moduleName => $moduleData) {
             $installInfo = new InstallInfo($moduleName, $moduleData->{'install-path'});
             if (isset($moduleData->env)) {
                 $installInfo->setEnvironment($moduleData->env);
             }
             if (isset($moduleData->installer)) {
                 $installInfo->setInstallerName($moduleData->installer);
             }
             if (isset($moduleData->{'disabled-bindings'})) {
                 foreach ($moduleData->{'disabled-bindings'} as $uuid) {
                     $installInfo->addDisabledBindingUuid(Uuid::fromString($uuid));
                 }
             }
             $moduleFile->addInstallInfo($installInfo);
         }
     }
 }