/** * Match provided request and if matched - return corresponding controller * * @param Mage_Core_Controller_Request_Http $request * @return Mage_Core_Controller_Front_Action|null */ public function match(Mage_Core_Controller_Request_Http $request) { // if URL has VDE prefix if (!$this->_isVdeRequest($request)) { return null; } // user must be logged in admin area if (!$this->_backendSession->isLoggedIn()) { return null; } // override VDE configuration $this->_overrideConfiguration(); // prepare request to imitate $this->_prepareVdeRequest($request); // apply rewrites $this->getFront()->applyRewrites($request); // match routers $controller = null; $routers = $this->_getMatchedRouters(); /** @var $router Mage_Core_Controller_Varien_Router_Abstract */ foreach ($routers as $router) { /** @var $controller Mage_Core_Controller_Varien_ActionAbstract */ $controller = $router->match($request); if ($controller) { $this->_editorState->update($this->_areaCode, $request, $controller); break; } } return $controller; }
public function testUpdateNavigationMode() { $this->_setAdditionalExpectations(); $request = $this->getMock('Mage_Core_Controller_Request_Http', array('getParam', 'isAjax', 'getPathInfo'), array(), '', false); $controller = $this->getMock('Mage_Adminhtml_Controller_Action', array('getFullActionName'), array(), '', false); $request->expects($this->once())->method('getParam')->with('handle', '')->will($this->returnValue('')); $request->expects($this->once())->method('isAjax')->will($this->returnValue(false)); $controller->expects($this->once())->method('getFullActionName')->will($this->returnValue('index')); $this->_backendSession->expects($this->at(0))->method('setData')->with('vde_current_handle', 'index'); $request->expects($this->once())->method('getPathInfo')->will($this->returnValue('/')); $this->_backendSession->expects($this->at(1))->method('setData')->with('vde_current_url', '/'); $this->_backendSession->expects($this->at(2))->method('setData')->with('vde_current_mode', Mage_DesignEditor_Model_State::MODE_NAVIGATION); $this->_urlModelFactory->expects($this->once())->method('replaceClassName')->with(self::URL_MODEL_NAVIGATION_MODE_CLASS_NAME); $this->_layoutFactory->expects($this->once())->method('createLayout')->with(array('area' => self::AREA_CODE), self::LAYOUT_NAVIGATION_CLASS_NAME); $this->_objectManager->expects($this->once())->method('addAlias')->with(self::LAYOUT_UPDATE_RESOURCE_MODEL_CORE_CLASS_NAME, self::LAYOUT_UPDATE_RESOURCE_MODEL_VDE_CLASS_NAME); $this->_model->update(self::AREA_CODE, $request, $controller); }