Public Member Functions | |
setDefault ($key, $value=null) | |
getDefault ($key=null) | |
getRequest () | |
getResponse () | |
addRouter ($name, Mage_Core_Controller_Varien_Router_Abstract $router) | |
getRouter ($name) | |
init () | |
dispatch () | |
getRouterByRoute ($routeName) | |
getRouterByFrontName ($frontName) | |
rewrite () | |
Public Attributes | |
const | XML_STORE_ROUTERS_PATH = 'web/routers' |
Protected Attributes | |
$_defaults = array() | |
$_routers = array() | |
$_urlCache = array() |
Definition at line 28 of file Front.php.
addRouter | ( | $ | name, | |
Mage_Core_Controller_Varien_Router_Abstract $ | router | |||
) |
Adding new router
string | $name | |
Mage_Core_Controller_Varien_Router_Abstract | $router |
Definition at line 90 of file Front.php.
00091 { 00092 $router->setFront($this); 00093 $this->_routers[$name] = $router; 00094 return $this; 00095 }
dispatch | ( | ) |
Definition at line 141 of file Front.php.
00142 { 00143 $request = $this->getRequest(); 00144 $request->setPathInfo()->setDispatched(false); 00145 00146 Varien_Profiler::start('mage::dispatch::db_url_rewrite'); 00147 Mage::getModel('core/url_rewrite')->rewrite(); 00148 Varien_Profiler::stop('mage::dispatch::db_url_rewrite'); 00149 00150 Varien_Profiler::start('mage::dispatch::config_url_rewrite'); 00151 $this->rewrite(); 00152 Varien_Profiler::stop('mage::dispatch::config_url_rewrite'); 00153 00154 Varien_Profiler::start('mage::dispatch::routers_match'); 00155 $i = 0; 00156 while (!$request->isDispatched() && $i++<100) { 00157 foreach ($this->_routers as $router) { 00158 if ($router->match($this->getRequest())) { 00159 break; 00160 } 00161 } 00162 } 00163 Varien_Profiler::stop('mage::dispatch::routers_match'); 00164 if ($i>100) { 00165 Mage::throwException('Front controller reached 100 router match iterations'); 00166 } 00167 00168 Varien_Profiler::start('mage::app::dispatch::send_response'); 00169 $this->getResponse()->sendResponse(); 00170 Varien_Profiler::stop('mage::app::dispatch::send_response'); 00171 00172 return $this; 00173 }
getDefault | ( | $ | key = null |
) |
getRequest | ( | ) |
getResponse | ( | ) |
getRouter | ( | $ | name | ) |
getRouterByFrontName | ( | $ | frontName | ) |
Definition at line 196 of file Front.php.
00197 { 00198 // empty route supplied - return base url 00199 if (empty($frontName)) { 00200 $router = $this->getRouter('standard'); 00201 } elseif ($this->getRouter('admin')->getRouteByFrontName($frontName)) { 00202 // try standard router url assembly 00203 $router = $this->getRouter('admin'); 00204 } elseif ($this->getRouter('standard')->getRouteByFrontName($frontName)) { 00205 // try standard router url assembly 00206 $router = $this->getRouter('standard'); 00207 } elseif ($router = $this->getRouter($frontName)) { 00208 // try custom router url assembly 00209 } else { 00210 // get default router url 00211 $router = $this->getRouter('default'); 00212 } 00213 00214 return $router; 00215 }
getRouterByRoute | ( | $ | routeName | ) |
Definition at line 175 of file Front.php.
00176 { 00177 // empty route supplied - return base url 00178 if (empty($routeName)) { 00179 $router = $this->getRouter('standard'); 00180 } elseif ($this->getRouter('admin')->getFrontNameByRoute($routeName)) { 00181 // try standard router url assembly 00182 $router = $this->getRouter('admin'); 00183 } elseif ($this->getRouter('standard')->getFrontNameByRoute($routeName)) { 00184 // try standard router url assembly 00185 $router = $this->getRouter('standard'); 00186 } elseif ($router = $this->getRouter($routeName)) { 00187 // try custom router url assembly 00188 } else { 00189 // get default router url 00190 $router = $this->getRouter('default'); 00191 } 00192 00193 return $router; 00194 }
init | ( | ) |
Definition at line 111 of file Front.php.
00112 { 00113 Mage::dispatchEvent('controller_front_init_before', array('front'=>$this)); 00114 00115 $routersInfo = Mage::app()->getStore()->getConfig(self::XML_STORE_ROUTERS_PATH); 00116 00117 Varien_Profiler::start('mage::app::init_front_controller::collect_routers'); 00118 foreach ($routersInfo as $routerCode => $routerInfo) { 00119 if (isset($routerInfo['disabled']) && $routerInfo['disabled']) { 00120 continue; 00121 } 00122 if (isset($routerInfo['class'])) { 00123 $router = new $routerInfo['class']; 00124 if (isset($routerInfo['area'])) { 00125 $router->collectRoutes($routerInfo['area'], $routerCode); 00126 } 00127 $this->addRouter($routerCode, $router); 00128 } 00129 } 00130 Varien_Profiler::stop('mage::app::init_front_controller::collect_routers'); 00131 00132 Mage::dispatchEvent('controller_front_init_routers', array('front'=>$this)); 00133 00134 // Add default router at the last 00135 $default = new Mage_Core_Controller_Varien_Router_Default(); 00136 $this->addRouter('default', $default); 00137 00138 return $this; 00139 }
rewrite | ( | ) |
Definition at line 217 of file Front.php.
00218 { 00219 $request = $this->getRequest(); 00220 $config = Mage::getConfig()->getNode('global/rewrite'); 00221 if (!$config) { 00222 return; 00223 } 00224 foreach ($config->children() as $rewrite) { 00225 $from = (string)$rewrite->from; 00226 $to = (string)$rewrite->to; 00227 if (empty($from) || empty($to)) { 00228 continue; 00229 } 00230 $pathInfo = preg_replace($from, $to, $request->getPathInfo()); 00231 $request->setPathInfo($pathInfo); 00232 } 00233 }
setDefault | ( | $ | key, | |
$ | value = null | |||
) |
const XML_STORE_ROUTERS_PATH = 'web/routers' |