[TYPO3-mvc] Related objects inheriting from parent object default query settings

Claus Due claus at wildside.dk
Wed Dec 21 09:53:11 CET 2011


Hi Francois,

To my knowledge there is no reason why the Repository should not be instantiated in order to get default QuerySettings. It seems to make sense. I would be happy to take a look at that patch. If all goes well I'll have a look tonight :)

To explain the error you are getting with ObjectManager:

Non-prototype instances are fetched using ObjectManager->get($className), so use that instead and it should work.

Cheers,
Claus

On Dec 21, 2011, at 7:45 AM, François Suter wrote:

> Hi,
> 
> Any opinion from the Extbase big wigs? I think what I described is not an uncommon scenario and that problem should be addressed.
> 
>> I have the following situation: I have a "Report" object which has a
>> related "Owner" object, which is actually a fe_users entry. Quite
>> logically I don't want to show hidden/disabled reports, but the owners
>> may be disabled fe_users (former employees). To implement this, I simply
>> extended the Tx_Extbase_Domain_Repository_FrontendUserRepository with my
>> own class and set the enable fields to be ignored in the default query
>> settings.
>> 
>> The problem is that when related objects are fetched (be it eagerly or
>> lazily), the corresponding repository is not used, hence the default
>> query settings are not used either. Instead
>> Tx_Extbase_Persistence_QueryFactory::create() just looks up the storage
>> pid but no more.
>> 
>> I have tried to work out a patch where
>> Tx_Extbase_Persistence_QueryFactory::create() tries to instantiate the
>> corresponding repository. This proved a bit hard as my knowledge of
>> Extbase is not very deep. I have attached my draft here as I know it's
>> not good enough as it is and maybe I even missed the whole point. I
>> would be quite glad for feedback.
>> 
>> If you agree that this is indeed an issue, I will gladly accept help in
>> improving this patch. In particular I'm using t3lib_div:makeInstance to
>> the repository instead of $this->objectManager->create(), because I then
>> get the following error:
>> 
>> #1265203124: Object "Tx_Foo_Domain_Repository_BarRepository" is of not
>> of scope prototype, but only prototype is supported by create()
>> 
>> which is typically where my limited knowledge of Extbase fails me and I
>> don't know how to do this properly.
>> 
>> Versions: TYPO3 4.5.10-dev, hence Extbase 1.3.1-dev.
>> 
>> Note: additionally this patch adds a test in the TYPO3 persistence
>> backend when adding the storage pid condition, to avoid doing so when
>> there are no pids. This is apparently a consequence of the rest of my
>> patch. Maybe there's a way to avoid this, although the check seems to
>> make sense anyway.
>> 
>> Thanks in advance for your opinion and advice.
> 
> Thanks
> 
> -- 
> 
> Francois Suter
> Cobweb Development Sarl - http://www.cobweb.ch
> _______________________________________________
> 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