[TYPO3-dev] Extbase object storage with different extended models
Caspar Stuebs
caspar at gosign.de
Tue Apr 28 18:40:07 CEST 2015
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
--
--
Gosign media. GmbH | We web ideas.
Langenfelder Damm 67 Gewerbehof | 22525 Hamburg
Telefon 040-609 40 79-0
Handelsregister AG HH HRB 112197 | Geschäftsführung Bert Gogolin
Greenpeace energy: Gosign läuft mit ehrlichem Strom und Gas.
GLS Bank: Gosign wirtschaftet mit Gewissen.
More information about the TYPO3-dev
mailing list