Пример #1
0
 public static function i()
 {
     $class = __CLASS__;
     if (is_null(self::$_instance)) {
         self::$_instance = new $class();
     }
     return self::$_instance;
 }
Пример #2
0
if(!class_exists('Eden_Route_Function')){class Eden_Route_Function extends Eden_Class{protected static $_instance=NULL;protected $_route=array();public static function i(){$class=__CLASS__;if(is_null(self::$_instance)){self::$_instance=new $class();}return self::$_instance;}public function call($function){Eden_Route_Error::i()->argument(1,'string');$args=func_get_args();$function=array_shift($args);return $this->callArray($function,$args);}public function callArray($function,array $args=array()){Eden_Route_Error::i()->argument(1,'string');$function=$this->getRoute($function);return call_user_func_array($function,$args);}public function getRoute($route){Eden_Route_Error::i()->argument(1,'string');if($this->isRoute($route)){return $this->_route[strtolower($route)];}return $route;}public function getRoutes(){return $this->_route;}public function isRoute($route){return isset($this->_route[strtolower($route)]);}public function release($route){if($this->isRoute($route)){unset($this->_route[strtolower($route)]);}return $this;}public function route($route,$function){Eden_Route_Error::i()->argument(1,'string')->argument(2,'string');$function=$this->getRoute($function);$this->_route[strtolower($route)]=$function;return $this;}}}