本文整理匯總了PHP中Phprojekt_Loader::tryToLoadClass方法的典型用法代碼示例。如果您正苦於以下問題:PHP Phprojekt_Loader::tryToLoadClass方法的具體用法?PHP Phprojekt_Loader::tryToLoadClass怎麽用?PHP Phprojekt_Loader::tryToLoadClass使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phprojekt_Loader
的用法示例。
在下文中一共展示了Phprojekt_Loader::tryToLoadClass方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getModules
/**
* Returns a set of modules available and have Configuration sections.
*
* @return array Array with 'name' and 'label'.
*/
public function getModules()
{
$results = array();
// System settings
$model = Phprojekt_Loader::getModel('Core', 'General_Configuration');
if ($model) {
$results[] = array('name' => 'General', 'label' => Phprojekt::getInstance()->translate('General'));
}
// Module Configuration
foreach (scandir(PHPR_CORE_PATH) as $dir) {
$path = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $dir;
if ($dir == '.' || $dir == '..' || in_array($dir, self::$_excludePaths)) {
continue;
}
if (is_dir($path)) {
$configClass = Phprojekt_Loader::getModelClassname($dir, 'Configuration');
if (Phprojekt_Loader::tryToLoadClass($configClass)) {
$results[] = array('name' => $dir, 'label' => Phprojekt::getInstance()->translate($dir, null, $dir));
}
}
}
return $results;
}
示例2: getModules
/**
* Returns a set of modules available that have Setting.php files.
*
* @return array Array with 'name' and 'label'.
*/
public function getModules()
{
$results = array();
// System settings
$model = Phprojekt_Loader::getModel('Core', 'User_Setting');
if ($model) {
$results[] = array('name' => 'User', 'label' => Phprojekt::getInstance()->translate('User'));
}
$modelNotification = Phprojekt_Loader::getModel('Core', 'Notification_Setting');
if ($modelNotification) {
$results[] = array('name' => 'Notification', 'label' => Phprojekt::getInstance()->translate('Notification'));
}
// System modules settings
foreach (scandir(PHPR_CORE_PATH) as $dir) {
$path = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $dir;
if ($dir == '.' || $dir == '..' || in_array($dir, self::$_excludePaths)) {
continue;
}
if (is_dir($path)) {
$settingClass = Phprojekt_Loader::getModelClassname($dir, 'Setting');
if (Phprojekt_Loader::tryToLoadClass($settingClass)) {
$results[] = array('name' => $dir, 'label' => Phprojekt::getInstance()->translate($dir, null, $dir));
}
}
}
// User modules settings
foreach (scandir(PHPR_USER_CORE_PATH) as $dir) {
$path = PHPR_USER_CORE_PATH . $dir;
if ($dir == '.' || $dir == '..') {
continue;
}
if (is_dir($path)) {
$settingClass = Phprojekt_Loader::getModelClassname($dir, 'Setting');
if (Phprojekt_Loader::tryToLoadClass($settingClass, false, true)) {
$results[] = array('name' => $dir, 'label' => Phprojekt::getInstance()->translate($dir, null, $dir));
}
}
}
return $results;
}
示例3: testTryToLoadClass
/**
* Test tryToLoadClass
*/
public function testTryToLoadClass()
{
$this->assertTrue(Phprojekt_Loader::tryToLoadClass('Core_Models_User_Setting'));
$this->assertFalse(Phprojekt_Loader::tryToLoadClass('Timecard_Models_None'));
}