[TYPO3-mvc] Dependency Injection fails only in models

Frank Gerards F.Gerards at esolut.de
Thu Mar 22 10:21:26 CET 2012


Hi,

afaik only latest extbase version allows DI in models. 

Btw. Why would you want to insert a Repo in a model ? Seems like hurting the MVC concept ...

Greetz,
Frank

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Christian Peters
Gesendet: Donnerstag, 22. März 2012 10:17
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: [TYPO3-mvc] Dependency Injection fails only in models

Hello y'all,

I'm working on an extbase extension. I have some experience with flow but little with typo3 and extbase.

However, I want to inject a repository in my model and it simply does not
work: The inject*() function does not get called. The code is copied from a controller.

The injection works in the controller, but not in the models. This is my
code:


/**
	 * imageRepository
	 *
	 * @var Tx_MeineExtension_Domain_Repository_ImageRepository
	 */
	protected $imageRepository;

        /**
	 * injectImageRepository
	 *
	 * @param Tx_MeineExtension_Domain_Repository_ImageRepository $imageRepository
	 * @return void
	 */
	public function
injectImageRepository(Tx_MeineExtension_Domain_Repository_ImageRepository
$imageRepository) {
                die('This was called.');
                $this->imageRepository = $imageRepository;
	}


No errors, no clues. the inject* is simply not getting called.

I receive lot's of extbase / typo3 extmanager / typo3 persistence etc.
Notices when I turn E_ALL | E_STRICT on.

Among them:


Notice: Undefined index: Tx_MyExtension_Domain_Model_UserModel in C:\xampp\htdocs\t3\typo3\sysext\extbase\Classes\Persistence\Mapper\DataMapFactory.php
on line 96




Notice: Undefined index: tx_bphilcore_UserModel_image_mm in C:\xampp\htdocs\t3\typo3\sysext\extbase\Classes\Persistence\Mapper\DataMapFactory.php
on line 152



UserModel is my model that get's the imageRepository injected.

I have tried very much and am down to my last now. Has anyone a clue what I can try next?

Caches are flushed.

Thank you for your help.

Chris
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list