本文整理汇总了PHP中AutoLoader类的典型用法代码示例。如果您正苦于以下问题:PHP AutoLoader类的具体用法?PHP AutoLoader怎么用?PHP AutoLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AutoLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startAutoLoader
private function startAutoLoader()
{
require_once 'AutoLoader.php';
$auto_loader = new AutoLoader();
$auto_loader->addNamespace('sweb', $this->sWebPath);
$auto_loader->addNamespace($this->pageNS, $this->pagePath);
$auto_loader->register();
}
示例2: createInstance
public static function createInstance()
{
if (self::$autoLoader === null) {
self::$autoLoader = new AutoLoader();
}
return self::$autoLoader;
}
示例3: instance
/**
* Returns the instance of the AutoLoader Singleton or instantiates a new one
* @return AutoLoader
*/
public static function instance($rootDirectory = null, $reloadClassMap = true, $fileExt = null)
{
if (self::$instance == null) {
self::$instance = new AutoLoader($rootDirectory, $reloadClassMap, $fileExt);
}
return self::$instance;
}
示例4: createInstance
public static function createInstance()
{
if (self::$instance == NULL) {
self::$instance = new AutoLoader();
}
return self::$instance;
}
示例5: constructor
/**
* @see IController::constructor()
*/
public function constructor()
{
// Link loader to controller
// and the controller instance to itself
$this->load = Loader::$instance;
self::$instance =& $this;
// Method and argument back references.
if (isset($_GET["m"])) {
$m = filter_var($_GET["m"], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
}
if (isset($_GET["a"])) {
$a = filter_var($_GET["a"], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
}
if (isset($m)) {
$this->method = $m;
}
if (isset($a)) {
$this->arg = $a;
}
AutoLoader::getInstance();
/*
* Changing the working directory to "application"
* since we don't really need anything from the system folder.
*/
chdir("application");
}
示例6: getInstance
public static function getInstance()
{
if (is_null(self::$instance)) {
self::$instance = new AutoLoader();
}
return self::$instance;
}
示例7: Factory
public static function Factory($default_page = null, $requireLogin = true)
{
$prefs = UserPreferences::Instance(EGS_USERNAME);
$default_page = $prefs->getPreferenceValue('default_page', 'shared');
if ($default_page == null) {
$ao = AccessObject::Instance();
$default_page = 'module,' . $ao->getDefaultModule();
}
if (get_config('SETUP')) {
if (defined('MODULE')) {
$default_page = MODULE;
}
}
$router = RouteParser::Instance();
$modules = array();
if (!$requireLogin || isLoggedIn()) {
foreach ($router->getDispatch() as $key => $dispatch) {
if (($key == 'group' || $key == 'module' || strstr($key, 'submodule')) && !empty($dispatch)) {
$modules[$key] = $dispatch;
}
}
if (empty($modules)) {
// Default page contains permission type and permission name
// i.e. type is group or module
$array = explode(',', $default_page);
$modules[$array[0]] = $array[1];
}
} else {
$modules['module'] = 'login';
}
$al =& AutoLoader::Instance();
return $modules;
}
示例8: setUp
protected function setUp()
{
parent::setUp();
// Fancy dance to trigger a rebuild of AutoLoader::$autoloadLocalClassesLower
$this->mergeMwGlobalArrayValue('wgAutoloadLocalClasses', ['TestAutoloadedLocalClass' => __DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php', 'TestAutoloadedCamlClass' => __DIR__ . '/../data/autoloader/TestAutoloadedCamlClass.php', 'TestAutoloadedSerializedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedSerializedClass.php']);
AutoLoader::resetAutoloadLocalClassesLower();
$this->mergeMwGlobalArrayValue('wgAutoloadClasses', ['TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php']);
}
示例9: getInstance
/**
* 获得实例的方法
* @return AutoLoader AutoLoader的实例
* @author winsen
*/
public static function getInstance()
{
if (is_null(self::$obj)) {
$class = __CLASS__;
self::$obj = new $class();
}
return self::$obj;
}
示例10: self
/**
* @return AutoLoader
*/
public static function &getInstance()
{
if (!self::$_instance instanceof self) {
self::$_instance = new self();
self::$_instance->initialize();
return self::$_instance;
} else {
return self::$_instance;
}
}
开发者ID:Teino1978-Corp,项目名称:Teino1978-Corp-flickr_.idea_.name,代码行数:13,代码来源:flickr_web_app_classes_AutoLoader.php
示例11: setUp
protected function setUp()
{
global $wgAutoloadLocalClasses, $wgAutoloadClasses;
parent::setUp();
// Fancy dance to trigger a rebuild of AutoLoader::$autoloadLocalClassesLower
$this->testLocalClasses = array('TestAutoloadedLocalClass' => __DIR__ . '/../data/autoloader/TestAutoloadedLocalClass.php', 'TestAutoloadedCamlClass' => __DIR__ . '/../data/autoloader/TestAutoloadedCamlClass.php', 'TestAutoloadedSerializedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedSerializedClass.php');
$this->setMwGlobals('wgAutoloadLocalClasses', $this->testLocalClasses + $wgAutoloadLocalClasses);
AutoLoader::resetAutoloadLocalClassesLower();
$this->testExtensionClasses = array('TestAutoloadedClass' => __DIR__ . '/../data/autoloader/TestAutoloadedClass.php');
$this->setMwGlobals('wgAutoloadClasses', $this->testExtensionClasses + $wgAutoloadClasses);
}
示例12: testRegisterUnregister
/**
* make sure autoload registers and unregisters correctly
*/
public function testRegisterUnregister()
{
$al_orig_count = count(spl_autoload_functions());
$al = new AutoLoader();
$al->register();
$al_count = count(spl_autoload_functions());
$this->assertSame($al_orig_count + 1, $al_count);
$al->unregister();
$al_count = count(spl_autoload_functions());
$this->assertSame($al_orig_count, $al_count);
$al->register();
$al_count = count(spl_autoload_functions());
$this->assertSame($al_orig_count + 1, $al_count);
$al_map = array();
$al_map[0] = $al;
$al_map[0]->unregister();
$al_count = count(spl_autoload_functions());
$this->assertSame($al_orig_count, $al_count);
///\out::e(spl_autoload_functions());
}
示例13: 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
}
示例14: registerDirectory
public static function registerDirectory($dirName)
{
$di = new DirectoryIterator($dirName);
foreach ($di as $file) {
if ($file->isDir() && !$file->isLink() && !$file->isDot()) {
// recurse into directories other than a few special ones
self::registerDirectory($file->getPathname());
} elseif (substr($file->getFilename(), -4) === '.php') {
$className = self::getFullNamespacedName($file->getPathName());
AutoLoader::registerClass($className, $file->getPathname());
}
}
}
示例15: load_classes
protected static function load_classes()
{
$store_key = array(__DIR__, '__autoload');
if (Store::has($store_key)) {
$classes = Store::get($store_key);
} else {
$classes = array();
$modules = array();
$dir = path('libs');
$itr = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir));
$pattern = '/^' . preg_quote($dir, '/') . '\\/(.+?)\\.php$/';
foreach ($itr as $elem) {
if ($elem->isFile() && preg_match($pattern, $elem->getPathname(), $match)) {
$class_name = $elem->getBasename('.php');
if ($class_name == basename($elem->getPath())) {
$modules[$class_name] = str_replace('/', '.', substr($elem->getPath(), strlen($dir) + 1));
} else {
if ($class_name !== __CLASS__) {
$classes[$class_name] = str_replace('/', '.', $match[1]);
}
}
}
}
foreach ($modules as $module_name => $module_path) {
foreach ($classes as $class_name => $class_path) {
if (strpos($class_path, $module_path) === 0) {
unset($classes[$class_name]);
}
}
}
$classes = $modules + $classes;
Store::set($store_key, $classes);
}
self::$classes = $classes;
}