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.

undefined variable: dispatcher

<?php
class ErrorController extends ControllerBase
{   
    public function show404Action()
    {
        $this->$dispatcher->forward(array(
            'controller' => 'index',
            'action'     => 'index'
        ));
        return false;
    }

    public function show401Action()
    {
        //echo "show401"; die();
    }

    public function show500Action()
    {

    }

}

When show404 action is fired, that code gives me the following notice:

PHP Notice: Undefined variable: dispatcher

Should I define $this->dispatcher somehow?



83.5k
Accepted
answer

It should be:

$this->dispatcher->forward(array(

instead of:

$this->$dispatcher->forward(array(