当前位置: 首页>>代码示例>>PHP>>正文


PHP AutoLoader::loadClass方法代码示例

本文整理汇总了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
}
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:38,代码来源:functions.php

示例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
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:52,代码来源:functions.php

示例3: setUp

 function setUp()
 {
     AutoLoader::loadClass('SVGMetadataExtractorTest');
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:4,代码来源:SVGMetadataExtractorTest.php

示例4: setUp

 protected function setUp()
 {
     parent::setUp();
     AutoLoader::loadClass('SVGMetadataExtractorTest');
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:5,代码来源:SVGMetadataExtractorTest.php

示例5: __autoload

 function __autoload($name)
 {
     AutoLoader::loadClass($name);
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:4,代码来源:AutoLoader.php

示例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;
}
开发者ID:Nessworthy,项目名称:buan,代码行数:20,代码来源:AutoLoader.php

示例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);
     }
 }
开发者ID:phpsmith,项目名称:IS4C,代码行数:32,代码来源:BaseLibsTest.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->setMwGlobals('wgCleanupPresentationalAttributes', true);
     AutoLoader::loadClass('Sanitizer');
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:6,代码来源:SanitizerTest.php


注:本文中的AutoLoader::loadClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。