ZF-10048: Fatal error: Call to a member function getParams() on a non-object in Zend/Navigation/Page/Mvc.php on line 133

Description

Zend Navigation should detect wether the page is from type mvc or uri.

You need the following configuration to reproduce this error:


<?xml version="1.0" encoding="UTF-8"?>
Dashboard
            /admin/index/indexdefault

$navConfig = new Zend_Config_Xml(APPLICATION_PATH . '/path/to/navigation.xml', 'nav');
$this->_navigation = new Zend_Navigation($navConfig);
var_dump($this->_navigation->toArray());

If you remove the comments from the type of page, the error get wings and will fly away. :) In my opinion Zend_Navigation should detect the page type automatically. Either is set then the typ is uri else it is mvc.

regards René

Comments

{quote} In my opinion Zend_Navigation should detect the page type automatically. Either is set then the typ is uri else it is mvc. {quote} It does! But what do you want? In your configuration stands uri and route? Do want an Uri-Page or a MVC-Page?

Extend the abstract page class and check:


abstract class Zend_Navigation_Page extends Zend_Navigation_Container
{
    public static function factory($options)
    {
        // …

        $hasUri = isset($options['uri']);
        $hasMvc = isset($options['action']) || isset($options['controller']) ||
                  isset($options['module']) || isset($options['route']);

        if ($hasMvc && !$hasUri) {
            require_once 'Zend/Navigation/Page/Mvc.php';
            return new Zend_Navigation_Page_Mvc($options);
        } elseif ($hasUri && !$hasMvc) {
            require_once 'Zend/Navigation/Page/Uri.php';
            return new Zend_Navigation_Page_Uri($options);
        } else {
            require_once 'Zend/Navigation/Exception.php';
            throw new Zend_Navigation_Exception(
                'Invalid argument: Unable to determine class to instantiate');
        }
    }
}

Fix is included in ZF-11372