Mage_Core_Controller_Front_Router Class Reference

List of all members.

Public Member Functions

 __construct ($config)
 getConfig ()
 addRoutes (Zend_Controller_Router_Interface $router)
 getUrl ($params=array())

Protected Attributes

 $_config = null


Detailed Description

Definition at line 28 of file Router.php.


Constructor & Destructor Documentation

__construct ( config  ) 

Definition at line 32 of file Router.php.

00033     {
00034         $this->_config = $config;
00035     }


Member Function Documentation

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 (  ) 

Definition at line 37 of file Router.php.

00038     {
00039         return $this->_config;
00040     }

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     }


Member Data Documentation

$_config = null [protected]

Definition at line 30 of file Router.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:54 2009 for Magento by  doxygen 1.5.8