php - symfony2 upgrade 2.0 > 2.3 issue with Symfony\Component\HttpFoundation\Session -
here's custom security listener (from sym 2.0)
namespace mine\userbundle\eventlistener; use symfony\component\security\http\event\interactiveloginevent; use symfony\component\security\core\securitycontext; use symfony\component\httpfoundation\session session; class securitylistener { protected $security; protected $session; /** * constructs new instance of securitylistener. * * @param securitycontext $security security context * @param session $session session */ public function __construct(securitycontext $security, session $session)//<-- here { //you can bring whatever need here, start should useful $this->security = $security; $this->session = $session; } /** * invoked after successful login. * * @param interactiveloginevent $event event */ public function onsecurityinteractivelogin(interactiveloginevent $event) { //your logic needs go here //you can addrole //even persist if want bring right tools constructor $security = $this->security; if ($security->gettoken()->getuser()->hasplus()) { $security->gettoken()->getuser()->addrole('role_plususer'); } } }
i assume namespace or such changed between 2.0 , 2.1 (i trying lift way 2.3 @ moment) because thrown error:
contexterrorexception: catchable fatal error: argument 2 passed mine\userbundle\eventlistener\securitylistener::__construct() must instance of symfony\component\httpfoundation\session, instance of symfony\component\httpfoundation\session\session given
ok, changing dependency to
use symfony\component\httpfoundation\session\session;
did trick. seemed totally opposite error message saying...
Comments
Post a Comment