[TYPO3-english] Extbase Dependency Injection fails oddly

Philipp Gampe philipp.gampe at typo3.org
Wed Aug 5 18:04:54 CEST 2015


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!



More information about the TYPO3-english mailing list