[TYPO3-english] problem after update to 6.2 with extension
Philipp Gampe
philipp.gampe at typo3.org
Fri Mar 28 12:15:53 CET 2014
Hi andreas,
andreas wrote:
> i may wrote wrong.
>
> in the regular controller for actions or repositories to call other it
> works fine with inject. really nice.
>
> but i have a problem in a hook.
Yes. The @inject methods only work for classes that are instantiated with
the object manager itself. Hooks are instantiated with the
GeneralUtility::makeInstance method.
Therefore the object manager does not work here and you have to create it
yourself.
I suggest that if you use legacy hooks, then you should use it just as a
wrapper to call a real extbase class.
$objectManager = GeneralUtility::makeInstance('...\ObjectManager');
$realHook = $objectManager->get('myClass', arg1, arg2);
$realHook->someMethod();
That way you can use the whole magic inside the real hook class.
Best regards
--
Philipp Gampe – PGP-Key 0AD96065 – TYPO3 UG Bonn/Köln
Documentation – Active contributor TYPO3 CMS
TYPO3 .... inspiring people to share!
More information about the TYPO3-english
mailing list