Running Facebook Sdk Everytime Mvc Runs
Posted 29 January 2014 - 10:23 AM
I am currently creating a Facebook App using the Yii FB SDK extension, with the FB App canvas being Yii.
I have created a controller where controller::actionIndex runs the required routine. That part is done and dusted. However, I am looking for advice on the best way to incorporate this functionality so it runs every time the MVC runs i.e. if a user runs another controller, this will run as a background process.
I would like some advice on the best way to run this. It would seem the obvious thing to do would be to include it in components/controller which all the other controllers extend. Is there a way to include this in components/controller in a way that it will automatically run when an action in a controller extending it is run?
Thanks in advance!
Posted 29 January 2014 - 11:05 AM
I would place the routine in a section that would be triggered by raiseEvent.
So I will end up raiseEvent in one controller, and also in the other controller. And if you want to be raised in a selection of controllers, than you subclass a controller, and place the raiseEvent in the before/afterAction.
Posted 30 January 2014 - 08:28 AM
Could you possibly give me an example of the code you would use to perform this? I would greatly appreciate it.
BTW would another option be to create a class that extends out the Facebook class and has the required functionality in the constructor, and have an instance of this class called from init() in the controller I want all controller that have this functionality to extend?
Posted 30 January 2014 - 09:35 AM