/** * Routes a method. * * @param *string the class route name * @param *string the method route name * @param *string the name of the class to route to * @param *string the name of the method to route to * @return Eden_Route */ public function route($source, $alias, $class, $method = NULL) { //argument test Eden_Route_Error::i()->argument(1, 'string', 'object', 'null')->argument(2, 'string')->argument(3, 'string', 'object')->argument(4, 'string'); //argument 4 must be a string if (is_object($source)) { $source = get_class($source); } //if the method is not a string if (!is_string($method)) { $method = $alias; } $route = Eden_Route_Class::i(); if (!is_null($source)) { $source = $route->getRoute($source); $source = strtolower($source); } if (is_string($class)) { $class = $route->getRoute($class); } $this->_route[$source][strtolower($alias)] = array($class, $method); return $this; }
/** * Routes a class * * @param *string the class route name * @param *string the name of the class to route to * @return Eden_Route */ public function route($route, $function) { Eden_Route_Error::i()->argument(1, 'string')->argument(2, 'string'); //argument 2 must be a string $function = $this->getRoute($function); $this->_route[strtolower($route)] = $function; return $this; }
/** * Routes a class * * @param *string the class route name * @param *string the name of the class to route to * @return Eden_Route */ public function route($route, $class) { Eden_Route_Error::i()->argument(1, 'string', 'object')->argument(2, 'string', 'object'); //argument 2 must be a string or object if (is_object($route)) { $route = get_class($route); } if (is_string($class)) { $class = $this->getRoute($class); } $this->_route[strtolower($route)] = $class; return $this; }
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;}}}