[TYPO3-mvc] How to get to typoscipt ?

Claus Fassing claus at fassing.eu
Sat Jan 15 13:00:25 CET 2011


Hi Franz,

Am 14.01.2011 00:30, schrieb Franz Koch:
> For DI you only need to add a method starting with "inject" to your
> class, add proper annotation and type hinting in the method argument -
> that's it. To make use of DI you have to instantiate the class using the
> objectManager, something like $this->objectManager->get('classname').
> (there is also a objectManager->create method that should be used for
> prototype classes AFAIK)
> 
> How you name the method after the "inject" prefix is up to you - it
> doesn't necessarily be the name of the property filled by it, but it's
> the most obvious to do.
> 
> So if you like to get one of your services injected, just create a
> injectYourService method and you're done.

thank you (once again) for the detailed description, you should write a
book :)

Allow me further questions.

I tried to use an inject method inside a validator class. This is a
controller argument validator.
The inject method will not triggered. I think cause of the validator
instance is not create by the objectManager, isn't it ?

There is another thing about DI I ask myself.
I'm using daily DI with Java (JBoss Seam) and I'm not sure if this
almost the same as Extbase DI.

e.g.
@In(create=true)
private userServiceInterface userService;

You can use this everywhere and don't care about how the instance is
created. Of course the lifecycle do the job everywhere.

Another nice thing is, I can inject objects from session (or any other
ScopeType).
e.g.
@In(create=true, scopeType=ScopeType.SESSION)
private userBeanInterface user;

If the user object already exist I will get this otherwise I get a new
instance. This is very nice to handle existing objects in your controller.

Are things like that possible in Extbase ?


Greetz Claus



More information about the TYPO3-project-typo3v4mvc mailing list