[TYPO3-mvc] questions: @lazy, @inject, @api, constructors

Sebastian Kurfürst sebastian at typo3.org
Fri Jan 15 08:09:41 CET 2010


Hi Barbara,

> 1. Which fields should  in general be annotated with @lazy? Is there
> some guideline?
In general an association which you do not traverse that often.

> 2. Is the @api annotation supported and if yes, when should it be used?
There are *no functional changes* if you use @api. It is a *Marker* for
Public API.
However, our API Documentation tool (PHP_UML), which can be found at
https://svn.typo3.org/TYPO3v4/CoreProjects/MVC/doc_extbase/ (see
Scripts/RenderAPI.php), only renders the methods which have the @api
annotation.

That's very important: All methods inside Extbase which have @api
annotated belong to the public API, all others do NOT (even though they
might be public methods due to technical reasons).

> 3. Is the @inject annotation supported? In the blog example,
> t3lib_div::makeInstance() is used for accessing the repositories in the
> controllers. Does it really create a new instance of a repository each
> time? If @inject is supported already, should it replace the
> t3lib_div::makeInstance function?
No, it is not supported right now, as dependency injection is not yet
supported.

> 4. Is there a guideline/good practice rule which defines which fields of
> a class should be initialized in its constructor?
- definitely all ObjectStorages (Tx_Extbase_Persistence_ObjectStorage)
- everything which is needed to make a domain object valid according to
your domain

I hope this helps a bit :-)

Greets,
Sebastian


More information about the TYPO3-project-typo3v4mvc mailing list