[TYPO3-english] Can Extbase Repository with STI return objects of subclasses?

Richard Davies richard at ocular.co.nz
Mon Aug 24 23:01:39 CEST 2015


Hi Victor,

You have to ensure your ext_typoscript_setup is written correctly. After
that make sure you clear the install tool cache, uninstall reinstall etc.

Your mappings need to include the subclasses in the parent class and
mapping in the subclasses back to the parent table just like in the
example.

config.tx_extbase.persistence.classes {
>     Tx_MyExtension_Domain_Model_Organization {
>         mapping {
>             tableName = tx_myextension_domain_model_party
>             recordType = Tx_MyExtension_Domain_Model_Organization
>         }
>        * subclasses {
>             Tx_MyExtension_Domain_Model_Company = Tx_MyExtension_Domain_Model_Company
>             Tx_MyExtension_Domain_Model_ScientificInstitution = Tx_MyExtension_Domain_Model_ScientificInstitution
>         }*
>     }
>     Tx_MyExtension_Domain_Model_Person {
>         mapping {
>             tableName = tx_myextension_domain_model_party
>             recordType = Tx_MyExtension_Domain_Model_Person
>         }
>     }
>     Tx_MyExtension_Domain_Model_Company {
>        * mapping {
>             tableName = tx_myextension_domain_model_party
>             recordType = Tx_MyExtension_Domain_Model_Company
>         }*
>     }
>     Tx_MyExtension_Domain_Model_ScientificInstitution {
>        * mapping {
>             tableName = tx_myextension_domain_model_party
>             recordType = Tx_MyExtension_Domain_Model_ScientificInstitution
>         }*
>     }
> }
>
>

Richard

On 25 August 2015 at 05:47, Viktor Livakivskyi <invisible.kinder at gmail.com>
wrote:

> Hi, List.
>
> I'm using STI (Single Table Inheritance) and I'd like Repository of parent
> Entity to return collection of child entities. From what I read in manual
> [1] it should be possible:
> "In the result set $organizationRepository there are domain objects of the
> class Tx_MyExtension_Domain_Model_Organization and all configured
> subclasses Tx_MyExtension_Domain_Model_Company and
> Tx_MyExtension_Domain_Model_ScientificInstitution are included."
>
> In my case repository always return only prent entities. Did I get the
> idea right or I'm missing something?
>
> [1]:
> https://docs.typo3.org/typo3cms/ExtbaseFluidBook/6-Persistence/5-modeling-the-class-hierarchy.html
> _______________________________________________
> TYPO3-english mailing list
> TYPO3-english at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-english
>


More information about the TYPO3-english mailing list