Gdn::factoryInstallFromConfig PHP Method

factoryInstallFromConfig() public static method

Installs a class to the factory with the settings from a configuration.
public static factoryInstallFromConfig ( mixed $Config, string $Alias = null )
$Config mixed The configuration of the factory definition. This argument can be of the following types: - string: The configuration will be looked up by calling inline{@link Gdn::Config()} - array: The configuration will be set from the array.
$Alias string The class alias to install into the factory. If omitted then it must be in the configuration. The factory will be installed from the configuration array depending on the following keys: - Alias: Optional if $Alias is passed as an argument. - FactoryType: Required. - Data: Optional. - Override Optional. - Dependencies Optional. Dependencies for the class can be defined as a subarray. Each item in the subarray will be passed to inline{@link Gdn::FactoryInstallDependencyFromConfig}. All of these values (except Dependencies) are passed to the corresponding argument in inline{@link Gdn::FactoryInstall()}.
    public static function factoryInstallFromConfig($Config, $Alias = null)
    {
        if (is_string($Config)) {
            $Config = self::config($Config);
        }
        if (is_null($Alias)) {
            $Alias = $Config['Alias'];
        }
        $FactoryType = $Config['FactoryType'];
        $Data = val('Data', $Config, null);
        $Override = val('Override', $Config, true);
        self::factoryInstall($Alias, $Config['ClassName'], $Config['Path'], $FactoryType, $Data, $Override);
        if (array_key_exists('Dependencies', $Config)) {
            $Dependencies = $Config['Dependencies'];
            foreach ($Dependencies as $Index => $DependencyConfig) {
                self::factoryInstallFromConfig($DependencyConfig, $Alias);
            }
        }
    }