Public Member Functions | |
__construct ($config) | |
getConfig () | |
addRoutes (Zend_Controller_Router_Interface $router) | |
getUrl ($params=array()) | |
Protected Attributes | |
$_config = null |
Definition at line 28 of file Router.php.
__construct | ( | $ | config | ) |
addRoutes | ( | Zend_Controller_Router_Interface $ | router | ) |
Definition at line 42 of file Router.php.
00043 { 00044 $frontName = $this->_config->getName(); 00045 $routeMatch = $frontName.'/:controller/:action/*'; 00046 $moduleName = (string)$this->_config->module; 00047 $routeParams = array('module'=>$moduleName, 'controller'=>'index', 'action'=>'index', '_frontName'=>$frontName); 00048 $route = new Zend_Controller_Router_Route($routeMatch, $routeParams); 00049 $router->addRoute($moduleName, $route); 00050 00051 return $this; 00052 }
getConfig | ( | ) |
getUrl | ( | $ | params = array() |
) |
Definition at line 54 of file Router.php.
00055 { 00056 static $reservedKeys = array('module'=>1, 'controller'=>1, 'action'=>1, 'array'=>1); 00057 00058 if (is_string($params)) { 00059 $paramsArr = explode('/', $params); 00060 $params = array('controller'=>$paramsArr[0], 'action'=>$paramsArr[1]); 00061 } 00062 00063 $url = Mage::getBaseUrl($params); 00064 00065 if (!empty($params['frontName'])) { 00066 $url .= $params['frontName'].'/'; 00067 } else { 00068 $url .= $this->_config->getName().'/'; 00069 } 00070 00071 if (!empty($params)) { 00072 $paramsStr = ''; 00073 foreach ($params as $key=>$value) { 00074 if (!isset($reservedKeys[$key]) && '_'!==$key{0} && !empty($value)) { 00075 $paramsStr .= $key.'/'.$value.'/'; 00076 } 00077 } 00078 00079 if (empty($params['controller']) && !empty($paramsStr)) { 00080 $params['controller'] = 'index'; 00081 } 00082 $url .= empty($params['controller']) ? '' : $params['controller'].'/'; 00083 00084 if (empty($params['action']) && !empty($paramsStr)) { 00085 $params['action'] = 'index'; 00086 } 00087 $url .= empty($params['action']) ? '' : $params['action'].'/'; 00088 00089 $url .= $paramsStr; 00090 00091 $url .= empty($params['array']) ? '' : '?' . http_build_query($params['array']); 00092 } 00093 00094 return $url; 00095 }
$_config = null [protected] |
Definition at line 30 of file Router.php.