Hi all,

What I am trying to do is pretty simple, and I can get it to work, but I encounter unexpected things along the road.

For example, I have a CfFrontend module and a CfArticle module. Both have controllers.

CfFrontend is at http://zf2/
CfArticle is at http://zf2/article

These two routes work, and they are configured in the respective module.config.php files of each module.

Now two strange things happen:

1. If a controller has an alias in the route configuration (i.e. NOT a class name), and it has an 'invokables' key in the 'controllers' configuration section with a key for the alias, it is not loaded. Examples later in this mail. However, if instead of 'invokables', 'factories' is used (with a valid factory for the alias) then it does work.

2. If in the second ('article') module we use the same setup with a valid factory, the controller is not found. It seems the factories are not stacked (not merged correctly). The last one loaded takes precedence. The last module in the application.config.php wins.

Examples:
module.config.php for 'CfArticle'

return array(
    'router' => array(
        'routes' => array(
            'cf-article' => array(
                'type' => 'Literal',
                'options' => array(
                    'route'    => '/article',
                    'defaults' => array(
//'controller' => 'article', // factories don't work here, incorrect merge? 'controller' => 'CfArticle\Controller\ArticleController',
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),

    'controller' => array(
'factories' => array( // using invokables is not possible here, only directly in route 'article' => 'CfArticle\Controller\ControllerFactory', // Does only work for last module loaded
        ),
    ),
);

module.config.php for CfFrontend (last one loaded: wins)

return array(

    'router' => array(
        'routes' => array(
            'cf-frontend' => array(
                'type' => 'Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'frontend', // works
                        'action'     => 'index',
                    ),
                ),
            ),
        ),
    ),

    'controller' => array( // works
'factories' => array( // using invokables is not possible here, only directly in route
            'frontend' => 'CfFrontend\Controller\ControllerFactory',
        ),
'invokables' => array( // does not work, not even if 'factories' is gone, just here as an example
            'frontend' => 'CfFronted\Controller\FrontendController',
        ),
    ),
);

Anyone any ideas, are these bugs I should fix?

-Bart


--
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to