Yii Framework Forum: Running Facebook Sdk Everytime Mvc Runs - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Running Facebook Sdk Everytime Mvc Runs Rate Topic: -----

#1 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 149
  • Joined: 04-November 12

Posted 29 January 2014 - 10:23 AM

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!

U4EA
0

#2 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 149
  • Joined: 04-November 12

Posted 29 January 2014 - 10:25 AM

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.
0

#3 User is offline   Pentium10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 174
  • Joined: 10-December 10

Posted 29 January 2014 - 11:05 AM

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.
0

#4 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 149
  • Joined: 04-November 12

Posted 29 January 2014 - 06:45 PM

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

#5 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 149
  • Joined: 04-November 12

Posted 30 January 2014 - 08:28 AM

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?
0

#6 User is offline   Pentium10 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 174
  • Joined: 10-December 10

Posted 30 January 2014 - 09:32 AM

share sample code to see what you are doing wrong
0

#7 User is offline   U4EA 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 149
  • Joined: 04-November 12

Posted 30 January 2014 - 09:35 AM

View PostPentium10, on 30 January 2014 - 09:32 AM, said:

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!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users