• 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

R

ragtek

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


For example:
the widget framework includes/extends the thread model with
PHP:
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']) . ')';
            }

            return $this->getConditionsForClause($sqlCond);
        } else {
            return $preCondition;
        }
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^^)
 
R

ragtek

Guest
#3
How about making a RagTekFrameWork add-on that includes all these shared methods, and then having your other products rely upon that?
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^^
 

Onimua

Well-known member
#4
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^^
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.
 
R

ragtek

Guest
#5
I don't mean for my add-ons!
As said, i have this already...
I have this already (there'S a helper directory in all my add-ons, which will be a seperate product in the feature..)^^
Nevermind, i'll write this again, after i had some english lessons:D