Gdn::factoryInstall PHP Method

factoryInstall() public static method

Install a class to the factory.
See also: Gdn_Factory::Install()
public static factoryInstall ( string $Alias, string $ClassName, string $Path = '', string $FactoryType = self::FactorySingleton, $Data = null )
$Alias string An alias for the class that will be used to retreive instances of it.
$ClassName string The actual name of the class.
$Path string The path to the class' file. You can prefix the path with ~ to start at the application root.
$FactoryType string The way objects will be instantiated for the class. One of (Gdn::FactoryInstance, Gdn::FactoryPrototype, Gdn::FactorySingleton).
    public static function factoryInstall($Alias, $ClassName, $Path = '', $FactoryType = self::FactorySingleton, $Data = null)
    {
        // Don't overwrite an existing definition.
        if (self::$_FactoryOverwrite === false && self::factoryExists($Alias)) {
            return;
        }
        self::factory()->install($Alias, $ClassName, $Path, $FactoryType, $Data);
        // Cache some of the more commonly used factory objects as properties.
        switch ($Alias) {
            case self::AliasConfig:
                self::$_Config = self::factory($Alias);
                break;
            case self::AliasLocale:
                self::$_Locale = self::factory($Alias);
                break;
            case self::AliasRequest:
                self::$_Request = self::factory($Alias);
                break;
            case self::AliasPluginManager:
                self::$_PluginManager = self::factory($Alias);
                break;
            case self::AliasSession:
                self::$_Session = null;
                break;
        }
    }

Usage Example

Example #1
0
 /**
  * Register the debug database that captures the queries.
  *
  * This event happens as early as possible so that all queries can be captured.
  *
  * @param Gdn_PluginManager $sender The {@link Gdn_PluginManager} firing the event.
  */
 public function gdn_pluginManager_afterStart_handler($sender)
 {
     $tmp = Gdn::factoryOverwrite(true);
     Gdn::factoryInstall(Gdn::AliasDatabase, 'Gdn_DatabaseDebug', dirname(__FILE__) . DS . 'class.databasedebug.php', Gdn::FactorySingleton, array('Database'));
     Gdn::factoryOverwrite($tmp);
     unset($tmp);
 }
All Usage Examples Of Gdn::factoryInstall