fromFile() public static method

Load config data from a file.
public static fromFile ( Gdn_Configuration $Parent, string $File, string $Name = 'Configuration' ) : Gdn_ConfigurationSource
$Parent Gdn_Configuration Parent config object
$File string Path to config file to load
$Name string Optional setting name
return Gdn_ConfigurationSource
Exemplo n.º 1
0
 /**
  * Loads an array of settings from a file into the object with the specified name;
  *
  * @param string $File A string containing the path to a file that contains the settings array.
  * @param string $Name The name of the variable and initial group settings.
  *   Note: When $Name is 'Configuration' then the data will be set to the root of the config.
  * @param boolean $Dynamic Optional, whether to treat this as the request's "dynamic" config, and
  *   to save config changes here. These settings will also be re-applied later when "OverlayDynamic"
  *   is called after all defaults are loaded.
  * @return boolean
  */
 public function load($File, $Name = 'Configuration', $Dynamic = false)
 {
     $ConfigurationSource = Gdn_ConfigurationSource::fromFile($this, $File, $Name);
     if (!$ConfigurationSource) {
         return false;
     }
     $UseSplitting = $this->splitting;
     $ConfigurationSource->splitting($UseSplitting);
     if (!$ConfigurationSource) {
         return false;
     }
     $SourceTag = "file:{$File}";
     $this->sources[$SourceTag] = $ConfigurationSource;
     if ($Dynamic) {
         $this->dynamic = $ConfigurationSource;
     }
     if (!$UseSplitting) {
         $this->massImport($ConfigurationSource->export());
     } else {
         $Loaded = $ConfigurationSource->export();
         self::mergeConfig($this->Data, $Loaded);
     }
 }