Monday, 9 September 2013

Redirect crashes Apache

Redirect crashes Apache

I am using Symfonoy2 with the FOSUserBundle in my webapp.
In order to show login and registration form on one pagem I created a
blank template (MyBundle:Static:home.html.twig), where I call both
Controllers (RegistrationController and SecurityController).
Works fine in general. So I want to avoid users from directly accessing
/login or /register, as this shall be covered by the two-form-template.
So I created a code snippet, which shall redirect to the correct template
(in my SecurityController):
$uri = $this->container->get('router')->generate('fos_user_security_login');
$check = $uri === $_SERVER['PHP_SELF'];
if($check) {
$engine = $this->container->get('templating');
$return = $engine->renderResponse('MyBundle:Static:home.html.twig');
} else {
$template = 'MyBundle:User:login.html.twig';
$return =
$this->container->get('templating')->renderResponse($template, $data);
}
return $return;
But when I now call /login directly, my Apache crashes an nothing happens
- browser stays blank, tries for another couple of seconds and then simply
says "Website not available".
What am I doing wrong here?
Please note:
The SecurityController class is not extending the Symfony base controller,
but FOS\UserBundle\Controller\SecurityController, which is extending
Symfony\Component\DependencyInjection\ContainerAware.

No comments:

Post a Comment