Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Event class improvements
  • Please add to Event class:
    1) Optional param priority in register method to specify the order in which the functions associated with a particular action are executed (default: 1). Higher numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added to the action.
    Priority can be 1-10. 2) Method remove:
    Event::remove('user_login', 'Class::method') - we delete event: Class::method
    Event::remove('user_login') - we delete all events for user_login
  • I agree with the priorities, but I don't see the reasoning behind 1-10... it should be any number. The lower the number, the higher it is on the priority list (ie: 1 is high, 999 is low).
  • Gregory A wrote on 01/17/11 3:51 pm:
    I agree with the priorities, but I don't see the reasoning behind 1-10... it should be any number. The lower the number, the higher it is on the priority list (ie: 1 is high, 999 is low).

    If 1 be high, then you can't add higher event. I think that 1-10 is good choice 1 - lower, 10 - higher, and default value can be 5. Same system implemented in punBB forum and I never had problems to extend it with hooks/events;)
  • I see a reason for wanting a delete/remove method. Not so sure about the priorities though. As you have no clue what is already in the event queue, and with which priority, there is no guaranty that one event will fire before or after another. What is the exact reason for this priority? What are you trying to achieve?
  • Harro Verton wrote on 01/18/11 11:47 pm:
    What is the exact reason for this priority? What are you trying to achieve?

    If we have priority for Events in event::register, then we can sort actions in event::trigger. I'm developing CMS on Fuel now and I use Event lib, as hooks in pubBB or wordpress.
    As example:
    In Twitter plugin I define:
    event::register('login_buttons', Twitter::button, 5);
    In Facebook plugin I define:
    event::register('login_buttons', Facebook::button, 1); And in template I define:
    event::trigger('login_buttons'); So Twitter login button will be first and Facebook button will be last (higher number high priority, lower number low priority, default priority: 5)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion