[Typo3-dev] extending extensions

Christian Jul Jensen christian at jul.net
Mon Jan 26 11:59:41 CET 2004


On Fri, 16 Jan 2004 01:28:20 +0100
Michael Zedeler <michael at zedeler.dk> wrote:

> Boris Nicolai wrote:
> 
> > morning,
> > I run into serious trouble as I want to develop another ext which
> > extends the tslib_fe.
> > the problem is as already sometimes discussed, what if I want to
> > install two ext that extend tslib_fe (or whichever class)?
> 
> I don't quite see the problem. Extending a class is done by simple 
> inheritance. It must be instantiation that is the problem.

And that's how it works in TYPO3. But if two extensions extend and
inherit form the same class ie. tslib_fe, it's not a trivial thing to
determine whether these extensions can work together and in which order
they should be instatiated if so.

> > so I thought a bit and maybe I got a solution without the time to
> > develop it:(
> > A basic-class could look if there are classes that extend this
> > class. if so, the basic-class creates an instance of this XCLASS,
> > and if a function of the basic-class is called then the basic-class
> > checks if this function doesn't exist in one of its
> > extension-classes.  [...cut...]
> 
> It sounds like there is a problem deciding what class to instantiate
> in a given context. This sort of problem is generally solved using the
> 
> factory design pattern.

And this is actualluy the way it is implemented and why classes should
be instantiated with t3lib_div::make_instance and not new. Because this
function checks the TYPO3 environment to see if any extension extends
the class that is about to be instantiated. As far as I see this
approach doesn't solve the situation where two extensions claims to be
the heir of a class.

The only thing I can imagine is a part of the extension manager that can
detect a warn about such incompatibilities.

If you have any suggestions on have this can be solved with class
inheritance, they mostly welcome.

-- 
./mvh Christian Jul Jensen
      Freelance webprogrammer
      TYPO3 Typehead Denmark




More information about the TYPO3-dev mailing list