本文整理汇总了PHP中AutoLoader::loadClass方法的典型用法代码示例。如果您正苦于以下问题:PHP AutoLoader::loadClass方法的具体用法?PHP AutoLoader::loadClass怎么用?PHP AutoLoader::loadClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AutoLoader
的用法示例。
在下文中一共展示了AutoLoader::loadClass方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: feng__autoload
/**
* Gets called, when an undefined class is being instanciated
*d
* @param_string $load_class_name
*/
function feng__autoload($load_class_name)
{
static $loader = null;
$class_name = strtoupper($load_class_name);
// Try to get this data from index...
if (isset($GLOBALS[AutoLoader::GLOBAL_VAR])) {
if (isset($GLOBALS[AutoLoader::GLOBAL_VAR][$class_name])) {
return include $GLOBALS[AutoLoader::GLOBAL_VAR][$class_name];
}
// if
}
// if
if (!$loader) {
$loader = new AutoLoader();
$loader->addDir(ROOT . '/application');
$loader->addDir(ROOT . '/environment');
$loader->addDir(ROOT . '/library');
$loader->setIndexFilename(ROOT . '/cache/autoloader.php');
}
// if
try {
$loader->loadClass($class_name);
} catch (Exception $e) {
try {
if (function_exists("__autoload")) {
__autoload($class_name);
}
} catch (Exception $ex) {
die('Caught Exception in AutoLoader: ' . $ex->__toString());
}
}
// try
}
示例2: feng__autoload
/**
* Gets called, when an undefined class is being instanciated
*d
* @param_string $load_class_name
*/
function feng__autoload($load_class_name) {
static $loader ;
//$loader = null;
$class_name = strtoupper($load_class_name);
// Try to get this data from index...
if(isset($GLOBALS[AutoLoader::GLOBAL_VAR])) {
if(isset($GLOBALS[AutoLoader::GLOBAL_VAR][$class_name])) {
return include $GLOBALS[AutoLoader::GLOBAL_VAR][$class_name];
} // if
} // if
//pre_print_r($loader) ;exit;
if(!$loader) {
$loader = new AutoLoader();
$loader->addDir(ROOT . '/application');
$loader->addDir(ROOT . '/environment');
$loader->addDir(ROOT . '/library');
//TODO Pepe: No tengo la conexion ni las clases de DB en este momento.. me conecto derecho
$temp_link = mysql_connect(DB_HOST, DB_USER, DB_PASS) ;
mysql_select_db(DB_NAME) ;
$res = mysql_query("SELECT name FROM ".TABLE_PREFIX."plugins WHERE is_installed = 1 AND is_activated = 1;");
while ($row = mysql_fetch_object($res)) {
$plugin_name = strtolower($row->name) ;
$dir = ROOT . '/plugins/'.$plugin_name.'/application' ;
if (is_dir($dir)) {
$loader->addDir($dir);
}
}
mysql_close($temp_link);
$loader->setIndexFilename(CACHE_DIR . '/autoloader.php');
} // if
try {
$loader->loadClass($class_name);
} catch(Exception $e) {
try {
if (function_exists("__autoload")) __autoload($class_name);
} catch(Exception $ex) {
die('Caught Exception in AutoLoader: ' . $ex->__toString());
}
} // try
} // __autoload
示例3: setUp
function setUp()
{
AutoLoader::loadClass('SVGMetadataExtractorTest');
}
示例4: setUp
protected function setUp()
{
parent::setUp();
AutoLoader::loadClass('SVGMetadataExtractorTest');
}
示例5: __autoload
function __autoload($name)
{
AutoLoader::loadClass($name);
}
示例6: fAutoLoader
/**
* @todo The exception handling doesn't seem to work if we register
* Buan\AutoLoader::loadClass() directly in spl_autload_register(), but using
* this global "inbetweener" function does. Might it be the fact that this
* routine defines a new class within the scope of a class method?
*
* @param string $className Class to load
* @return bool
*/
function fAutoLoader($className)
{
// Try to load class
try {
AutoLoader::loadClass($className);
} catch (Exception $e) {
// CLASS WAS NOT FOUND. DO NOTHING.
return false;
}
return true;
}
示例7: testAutoLoader
public function testAutoLoader()
{
// get codepath where session var is not array
CoreLocal::set('ClassLookup', false);
AutoLoader::loadClass('LocalStorage');
$this->assertEquals(true, class_exists('LocalStorage', false));
AutoLoader::loadMap();
$class_map = CoreLocal::get('ClassLookup');
$this->assertInternalType('array', $class_map);
$this->assertNotEmpty($class_map);
/**
Verify base classes and required libraries
were properly discovered
*/
$required_classes = array('AutoLoader', 'Authenticate', 'PreParser', 'Parser', 'BasicCorePage', 'TenderModule', 'DisplayLib', 'ReceiptLib', 'Database', 'Kicker', 'SpecialUPC', 'SpecialDept', 'DiscountType', 'PriceMethod', 'LocalStorage', 'FooterBox', 'Plugin', 'PrintHandler');
foreach ($required_classes as $class) {
$this->assertArrayHasKey($class, $class_map);
$this->assertFileExists($class_map[$class]);
}
$mods = AutoLoader::listModules('Parser');
$this->assertInternalType('array', $mods);
$this->assertNotEmpty($mods);
foreach ($mods as $m) {
$obj = new $m();
$this->assertInstanceOf('Parser', $obj);
}
$listable = array('DiscountType', 'FooterBox', 'Kicker', 'Parser', 'PreParser', 'PriceMethod', 'SpecialUPC', 'SpecialDept', 'TenderModule', 'TenderReport', 'DefaultReceiptDataFetch', 'DefaultReceiptFilter', 'DefaultReceiptSort', 'DefaultReceiptTag', 'DefaultReceiptSavings', 'ReceiptMessage', 'CustomerReceiptMessage', 'ProductSearch', 'DiscountModule', 'PrintHandler', 'TotalAction', 'VariableWeightReWrite', 'ItemNotFound');
foreach ($listable as $base_class) {
$mods = AutoLoader::listModules($base_class);
$this->assertInternalType('array', $mods);
}
}
示例8: setUp
protected function setUp()
{
parent::setUp();
$this->setMwGlobals('wgCleanupPresentationalAttributes', true);
AutoLoader::loadClass('Sanitizer');
}