public function getSearchDirs() { $return_value = array(); $class_file = __ClassLoader::getInstance()->getClassFile($component_class); if (!empty($class_file)) { $template_dir = dirname($class_file) . DIRECTORY_SEPARATOR . 'templates'; $return_value[] = $template_dir; } $return_value = array_merge($return_value, parent::getSearchDirs()); return $return_value; }
<?php spl_autoload_register(array(__ClassLoader::getInstance(), 'loadClassFile')); /** * The class loader has the relationship between classes and the .php files where they are defined in. * * @author aparraga * */ class __ClassLoader { private static $_instance = null; private $_mappings = array(); private $_autoloaders = array(); private $_classpaths = array(); private $_class_file_locator_ids = array(); /** * This method return a singleton instance of __ClassLoader * * @return __ClassLoader A singleton reference to the __ClassLoader */ public static function &getInstance() { if (self::$_instance == null) { if (!__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) { self::$_instance = __CacheManager::getInstance()->getCache()->getData('__ClassLoader__'); } //if still null: if (self::$_instance == null) { self::$_instance = new __ClassLoader(); }
public function &createContext($context_id, $context_base_dir, $configuration_file = null) { if ($this->hasContext($context_id)) { throw __ExceptionFactory::getInstance()->createException('Context already exists for context identifier ' . $context_id); } //create a class file locator for the context to create to $class_file_locator = new __ClassFileLocator($context_base_dir); __ClassLoader::getInstance()->addClassFileLocator($class_file_locator); //scann in depth starting from configuration location before scanning the context basedir if ($configuration_file != null) { $configuration_base_dir = dirname($configuration_file); if (strpos($configuration_base_dir, $context_base_dir) === false) { $configuration_class_file_locator = new __ClassFileLocator($configuration_base_dir); __ClassLoader::getInstance()->addClassFileLocator($configuration_class_file_locator); } } //do not read nor store into the cache the initial context in case of DEBUG_MODE active: if (__Lion::getInstance()->getRuntimeDirectives()->getDirective('DEBUG_MODE')) { $cache = null; //by default $context = null; } else { $cache = __CacheManager::getInstance()->getCache(); $context = $cache->getData('__Context__' . $context_id); if ($context != null) { $this->_addContext($context); } } //if no context has been read from cache: if ($context == null) { $context = new __Context($context_id, $context_base_dir); $this->_addContext($context); $context->loadConfiguration($configuration_file); if ($cache != null) { $cache->setData('__Context__' . $context_id, $context); } } //Startup the context $context->startup(); //return a reference to the already created context: return $context; }
private function _startupLionCore() { //Include lion constants: include 'libs' . DIRECTORY_SEPARATOR . 'core' . DIRECTORY_SEPARATOR . 'Constants.inc'; //Do not process HEAD request if LION_IGNORE_HEAD_REQUEST constant is set to true if (key_exists('REQUEST_METHOD', $_SERVER) && $_SERVER['REQUEST_METHOD'] == 'HEAD' && LION_IGNORE_HEAD_REQUEST == true) { exit; } //Include runtime directives: include LION_CORE_DIR . DIRECTORY_SEPARATOR . 'RuntimeDirectives.class.php'; $this->_runtime_directives = new __RuntimeDirectives(); //Include bootstrap classes: include LION_CORE_DIR . DIRECTORY_SEPARATOR . 'FileLocator.class.php'; include LION_CORE_DIR . DIRECTORY_SEPARATOR . 'FileResolver.class.php'; include LION_CACHE_DIR . DIRECTORY_SEPARATOR . 'Cache.class.php'; include LION_CACHE_DIR . DIRECTORY_SEPARATOR . 'CacheManager.class.php'; include LION_CACHE_DIR . DIRECTORY_SEPARATOR . 'ICacheHandler.interface.php'; include LION_CACHE_DIR . DIRECTORY_SEPARATOR . 'CacheHandler.class.php'; include LION_CACHE_DIR . DIRECTORY_SEPARATOR . 'CacheHandlerFactory.class.php'; include LION_CORE_DIR . DIRECTORY_SEPARATOR . 'ClassLoader.class.php'; //load framework includepath: __ClassLoader::getInstance()->addClassFileLocator(new __ClassFileLocator(LION_DIR)); include LION_CORE_DIR . DIRECTORY_SEPARATOR . 'ErrorHandling.php'; }