1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Add-On Collisions

Discussion in 'XenForo Development Discussions' started by digitalpoint, Jan 8, 2011.

  1. digitalpoint

    digitalpoint Well-Known Member

    So I started digging around the event listener system for hooking into existing classes, and I really like it so far since it's pretty generic and allows you to hook into most anything.

    But it got me thinking... what happens if a site has two different add-ons that are both extending the same method?
     
  2. Shadab

    Shadab Well-Known Member

    That depends upon whether the addons are calling the parent methods or not. If they are, both of the addons will work. Because of the way proxy classes are evaluated at runtime, parent:: for the second addon would be the overriding method of your first addon.

    Sample Class Hierarchy...
    Code:
    XenForo_ControllerPublic_Index
                ↑
    XFCP_Addon1_ControllerPublic_Index (Proxy Class)
                ↑
    Addon1_ControllerPublic_Index
                ↑
    XFCP_Addon2_ControllerPublic_Index (Proxy Class)
                ↑
    Addon2_ControllerPublic_Index
     
  3. ragtek

    ragtek Guest

    I hadn't time to check how it's working exactly, but it's working.

    I have 4 add-ons extending the _postSave method in the user datawriter, and all are working now ( i've forgotten to call the parent postSavein the past) nice. (that means, after a user registration, add-on 1 creates a welcome thread, add-on2 starts a conversation, add-on3 sends a mail to the admin, add-on4 is making some hidden stuff^^
     
  4. digitalpoint

    digitalpoint Well-Known Member

    I was hoping the proxy classes would handle it, but wasn't totally certain... Glad it does. :)
     
  5. Mike

    Mike XenForo Developer Staff Member

    And if they're not, frankly, they're wrong. (Unless they have some super specific reason not to...) :)
     
    Jeremy and ragtek like this.
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    I'm bumping this because I had a quick question on something. The "Callback Execution Order," if I set that to something really, really, extremely high (say 100000), I can nearly ensure that when XF creates the proxy classes, my class will be defined last. Correct? Question being is I'm thinking about setting it up so that I can do so with BBCM to allow for more modifications to inject their own BBCodes and have mine inherit them. ;)
     
  7. Mike

    Mike XenForo Developer Staff Member

    Yes, that should work.
     

Share This Page