/** * Get Menu model * * @return Mage_Backend_Model_Menu */ protected function _getMenu() { if (is_null($this->_menu)) { $this->_menu = $this->_menuConfig->getMenu(); } return $this->_menu; }
public function testGetMenuGenericExceptionIsNotLogged() { $this->_configMenuMock->expects($this->any())->method('getMergedConfig')->will($this->returnValue($this->_domDocumentMock)); $this->_logger->expects($this->never())->method('logException'); $this->_menuBuilderMock->expects($this->exactly(1))->method('getResult')->will($this->throwException(new Exception())); try { $this->_model->getMenu(); } catch (Exception $e) { return; } $this->fail("Generic Exception was not throwed"); }
/** * Convert xml config pathes to decorated names * * @param array $paths * @return array */ protected function _getSystemConfigPathsParts($paths) { $result = $urlParams = $prefixParts = array(); $scopeLabel = $this->helper('Mage_Backend_Helper_Data')->__('GLOBAL'); if ($paths) { /** @var $menu Mage_Backend_Model_Menu */ $menu = $this->_menuConfig->getMenu(); $item = $menu->get('Mage_Adminhtml::system'); // create prefix path parts $prefixParts[] = array('title' => $item->getModuleHelper()->__($item->getTitle())); $item = $menu->get('Mage_Adminhtml::system_config'); $prefixParts[] = array('title' => $item->getModuleHelper()->__($item->getTitle()), 'url' => $this->getUrl('adminhtml/system_config/')); $pathParts = $prefixParts; foreach ($paths as $pathData) { $pathDataParts = explode('/', $pathData['path']); $sectionName = array_shift($pathDataParts); $urlParams = array('section' => $sectionName); if (isset($pathData['scope']) && isset($pathData['scope_id'])) { switch ($pathData['scope']) { case 'stores': $store = Mage::app()->getStore($pathData['scope_id']); if ($store) { $urlParams['website'] = $store->getWebsite()->getCode(); $urlParams['store'] = $store->getCode(); $scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName(); } break; case 'websites': $website = Mage::app()->getWebsite($pathData['scope_id']); if ($website) { $urlParams['website'] = $website->getCode(); $scopeLabel = $website->getName(); } break; default: break; } } $pathParts[] = array('title' => $this->_configStructure->getElement($sectionName)->getLabel(), 'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams)); $elementPathParts = array($sectionName); while (count($pathDataParts) != 1) { $elementPathParts[] = array_shift($pathDataParts); $pathParts[] = array('title' => $this->_configStructure->getElementByPathParts($elementPathParts)->getLabel()); } $elementPathParts[] = array_shift($pathDataParts); $pathParts[] = array('title' => $this->_configStructure->getElementByPathParts($elementPathParts)->getLabel(), 'scope' => $scopeLabel); $result[] = $pathParts; $pathParts = $prefixParts; } } return $result; }