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

Same Method for different Add-ons

Discussion in 'XenForo Development Discussions' started by ragtek, Feb 6, 2011.

  1. ragtek

    ragtek Guest

    What should we do, if several different Add-ons needs the same method?

    For example:
    the widget framework includes/extends the thread model with
    public function prepareThreadConditions(array $conditions, array &$fetchOptions) {
    $preCondition parent::prepareThreadConditions($conditions$fetchOptions);
            if (!empty(
    $conditions['forum_ids'])) {
    $sqlCond = array($preCondition);

                if (!empty(
    $conditions['forum_ids'])) {
    $sqlCond[] = 'thread.node_id IN (' $this->_getDb()->quote($conditions['forum_ids']) . ')';

            } else {
    That's a very usefull method, which i'm using in my add-on too.

    In my board i know it's available, so i don't need to extend the model a second time, but what should i do in my released add-on?

    It's IMHO extrem ugly, to include this a second time:D
    All users which have installed the widgetframework and my global feed add-on have now two add-ons extending the thread model with the same method.

    Do we really need to extend it 2 times, or is there a better way?
    (sorry for the bad english, i hope you know what i mean^^)
  2. Kier

    Kier XenForo Developer Staff Member

    How about making a RagTekFrameWork add-on that includes all these shared methods, and then having your other products rely upon that?
    Vladislav Rastrusny and Jeremy like this.
  3. ragtek

    ragtek Guest

    I have this already (there'S a helper directory in all my add-ons, which will be a seperate product in the feature..)^^

    BUT IMHO it's still ugly to have the same method twice because some other 3rd parties use something similar.

    Nevermind, I'll see to find somebody, who can translate/explain exactly what i mean and i'll post it again^^
  4. Onimua

    Onimua Well-Known Member

    Can you not do something like this?
    • library/
      • RagtekApps
        • HelperFunctions
        • Add-on1
        • Add-on2
    Then just call upon RagtekApps_HelperFunctions within your add-ons? Just make sure you have instructions for those who have 2 or more of your add-ons.
  5. ragtek

    ragtek Guest

    I don't mean for my add-ons!
    As said, i have this already...
    Nevermind, i'll write this again, after i had some english lessons:D
  6. Nasr

    Nasr Well-Known Member

    I think he means for two different add on by two different developers?

Share This Page