I have a problem using doctrine into the service :
Fatal error: Call to a member function persist() on a non-object in /var/www/Symfony/src/mio/mioBundle/AuthenticationHandler.php on line 37
the code the service is:
services:
authentication_handler:
class: mio\mioBundle\AuthenticationHandler
arguments: [@router , @doctrine.orm.entity_manager ]
calls:
- [ setContainer, [ @service_container ] ]
the code the listener is:
class AuthenticationHandler extends ContainerAware implements AuthenticationSuccessHandlerInterface{
protected $router;
protected $em;
public function __construct(RouterInterface $router)
{
$this->router = $router;
}
public function __constructor(EntityManager $entityManager)
{
$this->em = $entityManager;
}
public function onAuthenticationSuccess(Request $request, TokenInterface $token)
{
$empleado = $token->getUser();
$empleado->setNombre("abeeeer");
$this->em->persist($empleado); //line 37
$this->em->flush();
//return new Response($token->getUsername());
return new RedirectResponse($this->router->generate('familia'));
}
}