I'm overriding the SecurityController from FOSUserBundle. I try to persist some data after the login but for that I need to add the "Request $request" parameter to the function protected function renderLogin but I get the following error:
Runtime Notice: Declaration of Utilisateurs\UtilisateursBundle\Controller\SecurityController::renderLogin() should be compatible with FOS\UserBundle\Controller\SecurityController::renderLogin(array $data)
Here is my code:
/**
* Renders the login template with the given parameters. Overwrite this function in
* an extended controller to provide additional data for the login template.
*
* @param array $data
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function renderLogin(array $data, Request $request)
{
function is_session_started()
{
if ( php_sapi_name() !== 'cli' ) {
if ( version_compare(phpversion(), '5.4.0', '>=') ) {
return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE;
} else {
return session_id() === '' ? FALSE : TRUE;
}
}
return FALSE;
}
if (is_session_started() == TRUE)
{
$session = $request->getSession();
$content = $session->get('result');
$idQuery = $session->get('query_id');
$authorId = $this->getUser()->getId();
$biblio = new Biblio;
$biblio->setAuthorId($authorId);
$biblio->setContent($content);
$biblio->setQueryId($idQuery);
$biblio->setDate(new \DateTime());
$em = $this->getDoctrine()->getManager();
$em->persist($biblio);
$em->flush();
$session->clear();
$response = $this->forward('BiblishareBundle:Profile:show');
return $response;
}
else
{
return $this->render('FOSUserBundle:Security:login.html.twig', $data);
}
}
Thank you for you help