Action doesn't seem to be run after redirect?

Hi there,

I have the following code:

    public function beforeExecuteRoute($dispatcher)
    {
        if (!$this->session->has('user')) {
            if ($dispatcher->getControllerName() == 'login' &&
                ($dispatcher->getActionName() == 'new' || $dispatcher->getActionName() == 'create')
            ) {
                return;
            }
            $this->response->redirect('login/new');
        }
    }

When I call

http://10.10.22.35/host_ui/

The browser address changes to

http://10.10.22.35/host_ui/login/new

The URL is re-written in Nginx

2014/04/16 07:36:15 [notice] 15281#0: *81 rewritten data: "/index.php", args: "_url=/login/new", client: 10.10.1.162, server: localhost, request: "GET /host_ui/login/new HTTP/1.1", host: "10.10.22.35"

However, the action in LoginController isn't hit

    /**
     * Handles a new Login
     *
     */
    public function newAction()
    {
        echo "In the Login new action...";
        die;
    }

Any ideas why this might be?

Thanks.



23.8k

OMG - panic over! I'm so embarrased ...

In the createAction in the same controller, I had the following

//        $this->dispatcher->forward(['controller' => 'index']);
        $this->dispatcher->forward(array('controller' => 'index'));

Passing the array literal to forward was causing a PHP parsing error. This is remedied by passing the array function and when the newAction is called, it isn't killed by the PHP parsing error.

I don't actually understand what's wrong with passing the array literal but that's another story!



34.0k

Pobably because of you php version



23.8k

Ah, OK. It's 5.4 - I'll look into that possibility :) Cheers.