本文整理汇总了PHP中ModuleManager::has方法的典型用法代码示例。如果您正苦于以下问题:PHP ModuleManager::has方法的具体用法?PHP ModuleManager::has怎么用?PHP ModuleManager::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModuleManager
的用法示例。
在下文中一共展示了ModuleManager::has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUser
/**
* @brief Assign a user to the current session.
*
* @param $id The user id to assign
*/
protected function setUser($id)
{
// Check if the user is active
$u = user::getUser($id);
if ($u == null) {
throw new UserException("Unassociated user id / Integrity failure", UserException::ERR_USER_UNASSOCIATED);
}
if (!$u->active) {
throw new UserException("User is not active, check audit log", UserException::ERR_USER_INACTIVE);
}
// TODO: Assign to session
if (ModuleManager::has('lepton.mvc.session')) {
session::set(User::KEY_USER_AUTH, $id);
}
if (class_exists('request')) {
$db = new DatabaseConnection();
$db->updateRow("UPDATE users SET lastlogin=NOW(), lastip=%s WHERE id=%d", request::getRemoteIp(), $id);
}
if (class_exists('UserEvents')) {
event::invoke(UserEvents::EVENT_USER_LOGIN, array('id' => $id));
}
}
示例2: load
/**
*
*/
static function load($module, $optional = false)
{
// Check if the path is globbed
if (strpos($module, '*') == strlen($module) - 1) {
$path = self::_mangleModulePath($module);
Console::debugEx(LOG_EXTENDED, __CLASS__, "Looking for modules matching %s from %s", $module, $path);
$f = glob($path);
sort($f);
$failed = false;
foreach ($f as $file) {
if (!ModuleManager::load(str_replace('*', basename($file, '.php'), $module))) {
$failed = true;
}
}
return !$failed;
}
// Check if the module is already loaded
if (ModuleManager::has($module)) {
logger::debug("Already loaded %s.", $module);
return true;
}
// Otherwise mangle the path
$path = self::_mangleModulePath($module);
/*
if (file_exists(APP_PATH.$modpath)) {
$path = APP_PATH.$modpath;
} elseif (file_exists(SYS_PATH.$modpath)) {
$path = SYS_PATH.$modpath;
} else {
$path = null;
}
*/
if ($path) {
if (file_exists(basename($path, '.php') . '.class.php')) {
$path = basename($path, '.php') . '.class.php';
}
if (file_exists($path)) {
self::$_lastmodule = $module;
Console::debugEx(LOG_BASIC, __CLASS__, "Loading %s (%s).", $module, str_replace(BASE_PATH, '', $path));
try {
ModuleManager::$_modules[strtolower($module)] = array();
ModuleManager::$_order[] = strtolower($module);
// Console::debugEx(LOG_DEBUG2,__CLASS__," path = %s", $path);
require $path;
array_pop(ModuleManager::$_order);
} catch (ModuleException $e) {
Console::debugEx(LOG_BASIC, __CLASS__, "Exception loading %s!", $module);
throw $e;
return false;
}
return true;
} else {
throw new ModuleException("Could not load module " . $module . ": Path not found");
return false;
}
} else {
Console::debugEx(LOG_BASIC, __CLASS__, "Failed to load %s.", $module);
return false;
}
}
示例3: getActiveUser
/**
* @brief Return the user record of the active user
*
* Returns null if no user is authenticated
*
* @todo Gracefully handle situations where the session is not available
* @return UserRecord The UserRecord of the active user
*/
static function getActiveUser()
{
if (ModuleManager::has('lepton.mvc.session')) {
$uid = session::get(User::KEY_USER_AUTH, null);
if ($uid) {
return user::getUser($uid);
}
throw new UserException("No active user", UserException::ERR_NO_ACTIVE_USER);
}
}