View rendered after redirect

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

View rendered after redirect

krmarien
This post has NOT been accepted by the mailing list yet.
Hi,

we have the following problem, in a view we have a URL generated with \Zend\View\Helper\Url. This URL needs a certain value (in this case token):

'shift_export' => array(
    'type'    => 'Zend\Mvc\Router\Http\Segment',
    'options' => array(
        'route' => '[/:language]/shift/export/:token/ical.ics',
        'constraints' => array(
            'language' => '[a-z]{2}',
            'token'    => '[a-zA-Z0-9_-]*',
        ),
        'defaults' => array(
            'controller' => 'shift',
            'action'     => 'export',
        ),
    ),
),

But if a user that has no access to that page he will be redirected to another page to login. But if we do a redirect like this:

$this->redirect()->toRoute(
    'index',
    array(
        'action' => 'index'
    )
);

return new ViewModel();

An error is thrown because in the view the token is null. But if there is a redirect, there is no need to render that view, because a redirect is done just after rendering. Is it possible to do the redirect before the rendering so no unneeded rendering is done?

Thanks,