[TYPO3-mvc] injectReflectionService() recent change?

Jochen Rau jochen.rau at typoplanet.de
Thu Oct 22 12:04:30 CEST 2009


Hey Xavier.

Xavier Perseguers wrote:
>> Could someone give me a hint how I should update my Repository classes
>> as I now get this:
>>
>> #1: PHP Catchable Fatal Error: Argument 1 passed to
>> Tx_Extbase_Persistence_Mapper_DataMapper::injectReflectionService()
>> must be an instance of Tx_Extbase_Reflection_Service, null given,
>> called in /path/to/extbase/Classes/Dispatcher.php on line 246 and
>> defined in /path/to/extbase/Classes/Persistence/Mapper/DataMapper.php
>> line 115
>>
>> I used to define an abstract class extending
>> Tx_Extbase_Persistence_Repository and having "parent::__construct()"
>> in my constructor. I basically don't need any datamapper coming from
>> Extbase as it uses a legacy MSSQL database for which I created my own
>> "data mapper".
>>
>> I tried to do this:
>>
>> public function __construct() {
>> $dispatcher = t3lib_div::makeInstance('Tx_Extbase_Dispatcher');
>> $dispatcher->initializeCache();
>> $dispatcher->initializeReflection();
>>
>> parent::__construct();
>>
>> ...
>> }
>
> Problem is related to changeset 1480 by Jochen:

[...]

> After further analyzing, change in Classes/Dispatches.php introduced the
> problem I encounter by introducing calls to
>
>
> $this->initializeCache();
> $this->initializeReflection();
>
> in method dispatch().
>
> Please give an advice how to prevent those stuff that were not needed
> before (and are still not "needed", just "prettier") from disrupting me.
> Thanks.

Be a friendly ghost. The change was necessary due to the implementation 
of annotation based persistence configuration. Furthermore, it separates 
concerns to make them testable.

The changeset was tested and does not touch the public API. Creating an 
own data mapper by a pro user (yes you are ;-) ) is always a little bit 
tricky.

The main obstacle her is that we have dependencies in the Repository 
constructor. These dependencies should better be injected (like it is 
done in FLOW3). That's not an easy task because we lack the DI container 
and don't want to force the developers to inject the persistence manager 
manually.

A possible solution would be to initialize all static class members of 
the Dispatcher at construction time.

Best solution: Put all the stuff in a method called initialize()
$dispatcher = new Tx_Extbase_Dispatcher;
$dispatcher->initialize();
$dispatcher->dispatch();

But that’s IMO not possible with TS as we have
userFunc = tx_extbase_dispatcher->dispatch

Second best solution: Put the two lines

$this->initializeCache();
$this->initializeReflection();

into __constructor()

I have applied this in a changset attached. Could you please test it and 
report if that works for you?

Any other suggestions?

I really appreciate your help as a beta tester.

Regards
Jochen


-- 
Every nit picked is a bug fixed

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: extbase_dispatcher.diff
URL: <http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/attachments/20091022/4c3bfdc3/attachment.txt>


More information about the TYPO3-project-typo3v4mvc mailing list