fromArray() public static method

Load config data from an array
public static fromArray ( Gdn_Configuration $Parent, array $ConfigData, string $Tag, string $Name = 'Configuration' ) : Gdn_ConfigurationSource
$Parent Gdn_Configuration Parent config object
$ConfigData array Config data array
$Tag string Internal friendly name
$Name string Optional setting name
return Gdn_ConfigurationSource
Example #1
0
 /**
  * Loads settings from an array into the object with the specified name;
  *
  * This array should be a hierarchical Vanilla config.
  *
  * @param string $ConfigData An array containing the configuration data
  * @param string $Tag A string descriptor of this config set
  * @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 loadArray($ConfigData, $Tag, $Name = 'Configuration', $Dynamic = true, $SaveCallback = null, $CallbackOptions = null)
 {
     $ConfigurationSource = Gdn_ConfigurationSource::fromArray($this, $ConfigData, $Tag, $Name);
     if (!$ConfigurationSource) {
         return false;
     }
     $UseSplitting = $this->splitting;
     $ConfigurationSource->splitting($UseSplitting);
     $SourceTag = "array:{$Tag}";
     $this->sources[$SourceTag] = $ConfigurationSource;
     if ($Dynamic) {
         $this->dynamic = $ConfigurationSource;
     }
     if (!$UseSplitting) {
         $this->massImport($ConfigurationSource->export());
     } else {
         self::mergeConfig($this->Data, $ConfigurationSource->export());
     }
     // Callback for saving
     if (!is_null($SaveCallback)) {
         $ConfigurationSource->assignCallback($SaveCallback, $CallbackOptions);
     }
 }