I'm curently developing an app on Symfony 2.5.0 using FOSUSerBundle, SonataAdminBundle and SonataUserBundle.
I've extended FOSUserbundle so my AppKernel.php has new Sonata\UserBundle\SonataUserBundle('FOSUserBundle') and I also generated my own Application\Sonata\UserBundle using Easy Extends.
In my Application\SonataUserBundle, i've overriden the ChangePasswordFOSUser1Controller as so:
use Symfony\Component\DependencyInjection\ContainerAware;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\HttpFoundation\Request;
use FOS\UserBundle\Model\UserInterface;
use Sonata\UserBundle\Controller\ChangePasswordFOSUser1Controller as BaseController;
class ChangePasswordFOSUser1Controller extends BaseController
{
public function changePasswordAction()
{
$user = $this->container->get('security.context')->getToken()->getUser();
if (!is_object($user) || !$user instanceof UserInterface)
{
throw new AccessDeniedException('This user does not have access to this section.');
}
$form = $this->container->get('fos_user.change_password.form');
$formHandler = $this->container->get('fos_user.change_password.form.handler');
$process = $formHandler->process($user);
if ($process)
{
$this->setFlash('fos_user_success', 'change_password.flash.success');
if ($user->getFirstConnection())
$user->setFirstConnection(false);
return new RedirectResponse($this->getRedirectionUrl($user));
}
return $this->container->get('templating')->renderResponse('SonataUserBundle:ChangePassword:changePassword.html.'.$this->container->getParameter('fos_user.template.engine'),
array('form' => $form->createView()));
}
/**
* {@inheritdoc}
*/
protected function getRedirectionUrl(UserInterface $user)
{
return $this->container->get('router')->generate('front_home');
}
/**
* @param string $action
* @param string $value
*/
protected function setFlash($action, $value)
{
$this->container->get('session')->getFlashBag()->set($action, $value);
}
}
The problem is: Whenever I go to my login page I see my controller's code printed twice in the "header section", right before the login form.
I've tried clearing my cache and VOILA ! cache is cleared but the same code gets printed twice in my shell. (yeah, I work with a shell)
I get the "bug" over and over again when clearing cache but on my login page it disappears after two page refresh.
Have anyone tried overriding that controller or got a similar error ? (would be a shame no one had)
Thx for the help !