I am switching from Yii1 to Symfony3 and would like to know how Symfony solves deadlock situation.
Yii loads user, url managers services automatically on each application load and they are available as Yii::app()->user, etc.. I have membership service and it should be loaded every time when user successfully logs in. So I extended Yii user class by adding onAfterLogin signal and set handler for that signal which loads membership service.
The scenario which causes problem is:
- Yii application creates user class instance
- If $_SESSION is empty Yii user class looks for user data in cookie and if it is available, it logs user from cookie thus raising onAfterLogin signal.
- onAfterLogin handler creates membership class
- In membership class constructor I access
Yii::app()->user - Yii application pushes user class instance into its service array, so that it could be available globally by
Yii::app()->user
Obviously 4 step raises error because Yii::app()->user is not available yet.
Does such problem exists in Symfony? If yes, how is it solved? My case is related with user and membership, but generally those classes may be others.
Aucun commentaire:
Enregistrer un commentaire