本文整理汇总了PHP中Gdn::FactoryExists方法的典型用法代码示例。如果您正苦于以下问题:PHP Gdn::FactoryExists方法的具体用法?PHP Gdn::FactoryExists怎么用?PHP Gdn::FactoryExists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Gdn
的用法示例。
在下文中一共展示了Gdn::FactoryExists方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetImports
/**
* Undocumented method.
*
* @todo Method GetImports() needs a description.
*/
public function GetImports()
{
if (!isset($this->Uses) || !is_array($this->Uses)) {
return;
}
// Load any classes in the uses array and make them properties of this class
foreach ($this->Uses as $Class) {
if (strlen($Class) >= 4 && substr_compare($Class, 'Gdn_', 0, 4) == 0) {
$Property = substr($Class, 4);
} else {
$Property = $Class;
}
// Find the class and instantiate an instance..
if (Gdn::FactoryExists($Property)) {
$this->{$Property} = Gdn::Factory($Property);
}
if (Gdn::FactoryExists($Class)) {
// Instantiate from the factory.
$this->{$Property} = Gdn::Factory($Class);
} elseif (class_exists($Class)) {
// Instantiate as an object.
$ReflectionClass = new ReflectionClass($Class);
// Is this class a singleton?
if ($ReflectionClass->implementsInterface("ISingleton")) {
eval('$this->' . $Property . ' = ' . $Class . '::GetInstance();');
} else {
$this->{$Property} = new $Class();
}
} else {
trigger_error(ErrorMessage('The "' . $Class . '" class could not be found.', $this->ClassName, '__construct'), E_USER_ERROR);
}
}
}
示例2: setlocale
Gdn::FactoryInstall(Gdn::AliasSession, 'Gdn_Session', PATH_LIBRARY_CORE . DS . 'class.session.php');
Gdn::FactoryInstall(Gdn::AliasAuthenticator, 'Gdn_Auth', PATH_LIBRARY_CORE . DS . 'class.auth.php', Gdn::FactorySingleton);
// Dispatcher.
Gdn::FactoryInstall(Gdn::AliasRouter, 'Gdn_Router', PATH_LIBRARY_CORE . DS . 'class.router.php', Gdn::FactorySingleton);
Gdn::FactoryInstall(Gdn::AliasDispatcher, 'Gdn_Dispatcher', PATH_LIBRARY_CORE . DS . 'class.dispatcher.php', Gdn::FactorySingleton);
// Smarty Templating Engine
Gdn::FactoryInstall('Smarty', 'Smarty', PATH_LIBRARY . DS . 'vendors' . DS . 'Smarty-2.6.25' . DS . 'libs' . DS . 'Smarty.class.php', Gdn::FactorySingleton);
Gdn::FactoryInstall('ViewHandler.tpl', 'Gdn_Smarty', PATH_LIBRARY_CORE . DS . 'class.smarty.php', Gdn::FactorySingleton);
// Application manager.
Gdn::FactoryInstall('ApplicationManager', 'Gdn_ApplicationManager', PATH_LIBRARY_CORE . DS . 'class.applicationmanager.php', Gdn::FactorySingleton);
// Theme manager
Gdn::FactoryInstall('ThemeManager', 'Gdn_ThemeManager', PATH_LIBRARY_CORE . DS . 'class.thememanager.php', Gdn::FactoryInstance);
Gdn::FactoryInstall(Gdn::AliasSlice, 'Gdn_Slice', PATH_LIBRARY_CORE . DS . 'class.slice.php', Gdn::FactorySingleton);
// Other objects.
Gdn::FactoryInstall('Dummy', 'Gdn_Dummy', PATH_LIBRARY_CORE . DS . 'class.dummy.php', Gdn::FactorySingleton);
if (!Gdn::FactoryExists(Gdn::AliasLocale)) {
require_once PATH_LIBRARY_CORE . DS . 'class.locale.php';
$Codeset = Gdn::Config('Garden.LocaleCodeset', 'UTF8');
$CurrentLocale = Gdn::Config('Garden.Locale', 'en-CA');
$SetLocale = str_replace('-', '_', $CurrentLocale) . '.' . $Codeset;
setlocale(LC_ALL, $SetLocale);
$Gdn_Locale = new Gdn_Locale($CurrentLocale, Gdn::Config('EnabledApplications'), Gdn::Config('EnabledPlugins'));
Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', PATH_LIBRARY_CORE . DS . 'class.locale.php', Gdn::FactorySingleton, $Gdn_Locale);
unset($Gdn_Locale);
}
// Execute other application startup.
foreach ($Gdn_EnabledApplications as $ApplicationName => $ApplicationFolder) {
// Include the application's bootstrap.
$Gdn_Path = PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'bootstrap.php';
if (file_exists($Gdn_Path)) {
include_once $Gdn_Path;