[TYPO3-dev] Extbase object storage with different extended models
Patrick Schriner
pschriner at gmx.de
Thu Apr 30 00:12:07 CEST 2015
Hi,
I'd avoid recordType at all cost. While it may seem to be right at first
glance, at least from my experience it definitely isn't practical. There
are hardly any benefits won from using it anyway (especially on the
fe_users and fe_groups tables).
As an alternative you could introduce a different fe_groups model where
recordType is not used as a type, but as a field mapping (never tried
that, but it might work).
Regards,
Patrick
On Tue, 28 Apr 2015 18:40:07 +0200, Caspar Stuebs <caspar at gosign.de> wrote:
> Dear list,
>
> within a project with an extensive frontend login system I am dealing
> with
> different types of frontend user groups.
>
> I have added two models and two corresponding record types
>
> config.tx_extbase.persistence.classes {
> Vendor\MyExt\Domain\Model\CompanyUserGroup {
> mapping {
> tableName = fe_groups
> recordType = Tx_MyExt_Domain_Model_CompanyUserGroup
> }
> }
> Vendor\MyExt\Domain\Model\CouncilUserGroup {
> mapping {
> tableName = fe_groups
> recordType = Tx_MyExt_Domain_Model_CouncilUserGroup
> }
> }
> }
>
> Both models extending the default extbase FrontendUserGroup:
>
> class CompanyUserGroup extends
> \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup { ... }
> class CouncilUserGroup extends
> \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup { ... }
>
> I have created an ContactPerson model (mapped to fe_users) which has a
> usergroup property. The addUsergroup() function needs to get an object of
> type \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup. Due to that I am
> able to add both types of groups to the ContactPerson. Even the
> findByUsergroup() function in the ContactPersonRepository is working as
> espected.
>
>
> But now I have the problem that I need to check if an given user is
> member
> in one of the usergroups. I have an object of type ContactPerson and one
> object of type CompanyUserGroup. But even if the ContactPerson is member
> of
> that specific group, the function
> call $contactPerson->getUsergroup()->offsetExists($companyUserGroup)
> returns false, because the object within the corresponding object storage
> is of type \TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup
>
> I have tried to convert the object $companyUserGroup into a default
> FrontendUserGroup, but that is not possible, because the custom model
> contains additional properties.
>
> Now I am wondering if it is possible to configure the object storage that
> it contains objects of the specific types instead of the default
> usergroup
> type.
>
> Or does anybody has another hint how I may do that check?
>
> Kind Regards.
> Caspar
>
--
More information about the TYPO3-dev
mailing list