/** * Register autoloader. * @return void */ public function register() { $cache = $this->getCache(); $key = $this->getKey(); if (isset($cache[$key])) { $this->list = $cache[$key]; } else { $this->rebuild(); } if (isset($this->list[strtolower(__CLASS__)]) && class_exists('NetteLoader', FALSE)) { NetteLoader::getInstance()->unregister(); } parent::register(); }
/** * Register autoloader. * @return void */ public function register() { $cache = $this->getCache(); $data = $cache['data']; if ($data['opt'] === array($this->scanDirs, $this->ignoreDirs, $this->acceptFiles)) { $this->list = $data['list']; } else { $this->rebuild(); } if (isset($this->list[strtolower(__CLASS__)]) && class_exists('NetteLoader', FALSE)) { NetteLoader::getInstance()->unregister(); } parent::register(); }
/** * Handles autoloading of classes or interfaces. * @param string * @return void */ public function tryLoad($type) { if ($this->list === NULL) { $this->list = array(); // prevents cycling $cache = $this->getCache(); $data = $cache['data']; $opt = array($this->scanDirs, $this->ignoreDirs, $this->acceptFiles); if ($data['opt'] === $opt) { $this->list = $data['list']; } else { $this->rebuild(); $cache['data'] = array('list' => $this->list, 'opt' => $opt); } if (isset($this->list[strtolower(__CLASS__)]) && class_exists('NetteLoader', FALSE)) { NetteLoader::getInstance()->unregister(); } } $type = strtolower($type); if (isset($this->list[$type])) { if ($this->list[$type] !== FALSE) { LimitedScope::load($this->list[$type]); self::$count++; } } else { if ($this->autoRebuild === NULL) { $this->autoRebuild = !$this->isProduction(); } if ($this->autoRebuild) { if (!$this->rebuilded) { $this->rebuild(); } if (isset($this->list[$type])) { LimitedScope::load($this->list[$type]); self::$count++; } else { $this->list[$type] = FALSE; } $cache = $this->getCache(); $cache['data'] = array('list' => $this->list, 'opt' => array($this->scanDirs, $this->ignoreDirs, $this->acceptFiles)); } } }
/** * Check and reset PHP configuration. */ if (!defined('PHP_VERSION_ID')) { $tmp = explode('.', PHP_VERSION); define('PHP_VERSION_ID', $tmp[0] * 10000 + $tmp[1] * 100 + $tmp[2]); } if (PHP_VERSION_ID < 50200) { throw new Exception('Nette Framework requires PHP 5.2.0 or newer.'); } @set_magic_quotes_runtime(FALSE); // @ - deprecated since PHP 5.3.0 /** * Load and configure Nette Framework */ define('NETTE', TRUE); define('NETTE_DIR', dirname(__FILE__)); define('NETTE_VERSION_ID', 906); // v0.9.6 define('NETTE_PACKAGE', 'PHP 5.2'); require_once dirname(__FILE__) . '/Utils/shortcuts.php'; require_once dirname(__FILE__) . '/Utils/exceptions.php'; require_once dirname(__FILE__) . '/Utils/Framework.php'; require_once dirname(__FILE__) . '/Utils/Object.php'; require_once dirname(__FILE__) . '/Utils/ObjectMixin.php'; require_once dirname(__FILE__) . '/Utils/Callback.php'; require_once dirname(__FILE__) . '/Loaders/LimitedScope.php'; require_once dirname(__FILE__) . '/Loaders/AutoLoader.php'; require_once dirname(__FILE__) . '/Loaders/NetteLoader.php'; NetteLoader::getInstance()->register();
<h1>Nette\Loaders\NetteLoader test</h1> <pre> <?php require_once '../../Nette/Loaders/NetteLoader.php'; /*use Nette\Debug;*/ $loader = NetteLoader::getInstance(); $loader->base = '../../Nette'; $loader->register(); Debug::dump('class Nette\\Debug successfully loaded');