Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

What's the purpose of dispatching requests with missing controller or action in the route match? #202

@wesperinteractive

Description

@wesperinteractive

I don't really understand the purpose of dispatching requests without a controller or an action in the route match.

I think Zend\Mvc\RouteListener (line 47.) should check the existence of the controller and action parameters too. If any of them are missing, it should trigger an error (MvcEvent::EVENT_DISPATCH_ERROR). The name of the error could be "Application::ERROR_ROUTER_INVALID_MATCH" or something similar to that. It should express that we have a route match, but it cannot be used to start the dispatch process.

If we do so, we can remove the default values from the getParam functions in the following files:

Zend\Mvc\DispatchListener

$controllerName = $routeMatch instanceof RouteMatch
    ? $routeMatch->getParam('controller', 'not-found')
    : 'not-found';

==>

$controllerName = $routeMatch instanceof RouteMatch
    ? $routeMatch->getParam('controller')
    : 'not-found';

Zend\Mvc\AbstractActionController

$action = $routeMatch->getParam('action', 'not-found');

==>

$action = $routeMatch->getParam('action')

These small things (and there are much more) make the life harder for people trying to understand the flow of MVC appliactions. We are in the middle of a dispatch event and the framework is checking whether controller or actions paramters are defined or not... It's weird. At least for me. Opinions?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions