Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Invo NotFoundPlugin - why abstract dispatcher class is used?

Hi in the NotFoundPlugin of the Invo app is besides Mvc\Dispatcher also the abstract base class used. Could somebody explain please for what reason this is done?

    use Phalcon\Dispatcher;
    use Phalcon\Mvc\Dispatcher as MvcDispatcher;
    if ($exception instanceof DispatcherException) {
        switch ($exception->getCode()) {
            case Dispatcher::EXCEPTION_HANDLER_NOT_FOUND:
            case Dispatcher::EXCEPTION_ACTION_NOT_FOUND:
                        'controller' => 'errors',
                        'action'     => 'show404'
                return false;

edited Mar '18

Because the plugin is only accessing two constant variables from that class, and not instantiating it.

It COULD use the MvcDispatcher to access those constants, since it inherits from abstract dispatcher.

Yeah, that is what I don't get - why not simply the child class was used here.

I dont think there's a specific reason for it... either will work, but yeah, it is superfluous the way it's written now.