Puli\Manager\Json\JsonStorage::loadConfigFile PHP Méthode

loadConfigFile() public méthode

Loads a configuration file from a path.
public loadConfigFile ( string $path, Puli\Manager\Api\Config\Config $baseConfig = null ) : Puli\Manager\Api\Config\ConfigFile
$path string The path to the configuration file.
$baseConfig Puli\Manager\Api\Config\Config The configuration that the loaded configuration will inherit its values from.
Résultat Puli\Manager\Api\Config\ConfigFile The loaded configuration file.
    public function loadConfigFile($path, Config $baseConfig = null)
    {
        return $this->loadFile($path, 'Puli\\Manager\\Api\\Config\\ConfigFile', array('baseConfig' => $baseConfig));
    }

Usage Example

Exemple #1
0
 private function loadConfigFile($homeDir, Config $baseConfig)
 {
     if (null === $homeDir) {
         return null;
     }
     Assert::fileExists($homeDir, 'Could not load Puli context: The home directory %s does not exist.');
     Assert::directory($homeDir, 'Could not load Puli context: The home directory %s is a file. Expected a directory.');
     // Create a storage without the factory manager
     $jsonStorage = new JsonStorage($this->getStorage(), new JsonConverterProvider($this), $this->getJsonEncoder(), $this->getJsonDecoder());
     $configPath = Path::canonicalize($homeDir) . '/config.json';
     try {
         return $jsonStorage->loadConfigFile($configPath, $baseConfig);
     } catch (FileNotFoundException $e) {
         // It's ok if no config.json exists. We'll work with
         // DefaultConfig instead
         return null;
     }
 }