[TYPO3-english] Extbase Dependency Injection fails oddly
Nicola Cerchiari
nicola.cerchiari at gmail.com
Wed Aug 5 18:24:17 CEST 2015
Hi Philipp,
not sure I got completely your answer as I'm not dealing with models and in
other classes apart from controllers the "@inject" annotation never worked
for me (but maybe I am missing something there).
If I don't use at least the constructor injection in custom classes the
ObjectManager is not injected at all, I get it correctly injected via
constructor and objectManager->get() method, though.
Anyways it was a problem with APC, that I'm investigating at the moment,
but disabling it made things work again.
Bests and thanks for the advices,
Nicola
Il giorno mer 5 ago 2015 alle ore 18:05 Philipp Gampe <
philipp.gampe at typo3.org> ha scritto:
> Hi Nicola,
>
> Nicola Cerchiari wrote:
>
> > Anyone can point me out what am I missing here cause I really can't get
> it
>
> You don't need to inject the object manager, because it is always there.
>
> If you use other classes, best is to use the @inject method.
>
> /**
> * @var \My\Namespace\Domain\Repository\MyRepository
> * @inject
> **/
> public myRepository;
>
>
> You need to use the fully qualified class name.
>
> Use the object manager only to get new instances for models you want to
> create.
> $myItem =
> $this->objectManager->get('My\\Namespace\\Domain\\Model\\MyItem');
> $this->myRepository->add($myItem);
>
> Best regards
> --
> Philipp Gampe – PGP-Key 0AD96065 – TYPO3 UG Bonn/Köln
> Documentation – Active contributor TYPO3 CMS
> TYPO3 .... inspiring people to share!
>
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
More information about the TYPO3-english
mailing list