Esempio n. 1
0
 public static function getInstance()
 {
     if (empty(self::$instance)) {
         self::$instance = new Engine_Registry();
     }
     return self::$instance;
 }
Esempio n. 2
0
 function __construct($module_name)
 {
     $module = new ReflectionClass($this);
     $this->registry = Engine_Registry::getInstance();
     $this->module_name = $module_name;
     $this->short_module_name = mb_strtolower($module_name);
     $this->module_path = $this->registry["path"]["modules"] . $module_name . "/";
     $this->setPath();
     $this->getConfig();
     if (isset($this->config["path"]["tpl"])) {
         $loader = new Twig_Loader_Filesystem($this->module_path . $this->config["path"]["tpl"]);
         if ($this->registry["twig_cache"]) {
             $twig = array('cache' => $this->registry["cache"], 'autoescape' => FALSE);
         } else {
             $twig = array('cache' => FALSE, 'autoescape' => FALSE);
         }
         $templates = new Twig_Environment($loader, $twig);
         $this->registry["twig_" . $this->short_module_name] = $templates;
     }
 }
Esempio n. 3
0
 public function setConfig($config)
 {
     $this->_config = $config;
     $this->registry = Engine_Registry::getInstance();
     $this->registry->set('siteName', "http://" . $this->_config["url"]);
     $this->registry->set('controller', $this->_config["path"]["root"] . $this->_config['path']['controller']);
     $this->registry->set('cache', $this->_config["path"]["root"] . $this->_config['path']['cache']);
     $this->registry->set('rootPublic', $this->_config["path"]["root"] . "/");
     $this->registry->set('rootDir', substr($this->_config["path"]["root"], 0, strpos($this->_config["path"]["root"], "public")));
     $action = empty($_GET['main']) ? '' : $_GET['main'];
     if (empty($action)) {
         $action = '';
     }
     $this->_config["url"] = "/" . $action;
     if (!empty($action)) {
         $this->_config["uri"] = substr($this->_config["uri"], 0, strrpos($this->_config["uri"], $action));
     }
     $this->_config["uripath"] = substr($this->registry["uri"], 0, strlen($this->registry["uri"]) - 1) . $this->registry["url"];
     foreach ($this->_config as $key => $val) {
         $this->registry->set($key, $val);
     }
 }
 public static function getDefaultCache()
 {
     if (Engine_Registry::isRegistered('cache-default')) {
         return Engine_Registry::get('cache-default');
     }
 }
 /**
  * Unset the default registry instance.
  * Primarily used in tearDown() in unit tests.
  * @returns void
  */
 public static function _unsetInstance()
 {
     parent::_unsetInstance();
     self::$_registry = null;
 }
 /**
  * Get the resource as specified by $type and $profile
  * 
  * @param string $type
  * @param string $profile
  * @return mixed
  */
 public function load($type, $profile = null)
 {
     $key = $type . '-' . ($profile ? $profile : 'default');
     if (!Engine_Registry::isRegistered($key)) {
         $object = $this->factory($type, $profile);
         if (!$object) {
             throw new Engine_ServiceLocator_Exception(sprintf('Unknown configuration format for class %s for %s', $class, $key));
         }
         Engine_Registry::set($key, $object);
     }
     return Engine_Registry::get($key);
 }
Esempio n. 7
0
 function __construct()
 {
     $this->registry = Engine_Registry::getInstance();
 }