Running Facebook Sdk Everytime Mvc Runs

Hi folks,

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!


Sorry mods, posted this in the wrong forum. Can you move it to Yii Framework Forum> Yii Framework Discussions> General Discussion for Yii 1.1.x please? Thanks.

Make use of events, and behaviors.

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.

Thank you very much. I need to sharpen up on events and behaviours it seems and I will do just that!

I am struggling to work out the best solution for this. My lack of experience with events and behaviors might be the issue.

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?

share sample code to see what you are doing wrong

Will do mate, thanks. Before I do though, I am going to try and work on it myself and see if I can resolve it (rather than putting the whole burden on you!).

Thanks again!