php - What should be the default value for $security? -


i'm working on method:

public function loginaction(request $request, security $security) {     $session = $request->getsession();     $session->remove('admin_project_id');      if ($security->has(security::authentication_error)) {         $error = $request->attributes->get(security::authentication_error);     } else {         $error = $session->get(security::authentication_error);         $session->remove(security::authentication_error);     }      return $this->render('pdonebundle:login:index.html.twig',         array_merge($this->defaultviewparams(), array(             'last_username' => $session->get(security::last_username),             'error'         => $error,             'include_sidebar' => false,             )         )     ); } 

but got error when it's called:

controller "groupdca\pdonebundle\controller\logincontroller::loginaction()" requires provide value "$security" argument (because there no default value or because there non optional argument after one).

what should default value argument? way i'm using right?

first of all, don't need pass $security argument. line use security, have access $request , attributes error.

secondly, saw tagged question symfony 2.7 , since version @2.6 new, short way of login introduced:

public function loginaction(request $request) {     $authenticationutils = $this->get('security.authentication_utils');      // login error if there 1     $error = $authenticationutils->getlastauthenticationerror();      // last username entered user     $lastusername = $authenticationutils->getlastusername();      return $this->render(         'security/login.html.twig',         array(             // last username entered user             'last_username' => $lastusername,             'error'         => $error,         )     ); } 

you can read more piece of code taken: how build traditional login form


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -