[TYPO3-mvc] Related objects inheriting from parent object default query settings
François Suter
fsu-lists at cobweb.ch
Mon Dec 19 11:51:28 CET 2011
Hi all,
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.
--
Francois Suter
Cobweb Development Sarl - http://www.cobweb.ch
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: related_objects.diff
URL: <http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/attachments/20111219/0d804c70/attachment-0001.txt>
More information about the TYPO3-project-typo3v4mvc
mailing list