[Flow] party and name conventions
Bastian Waidelich
bastian at typo3.org
Tue Jun 11 12:38:04 CEST 2013
Simon Schaufelberger (Schaufi) wrote:
Hey Simon,
> most important question: should i use them exactly like that (extending
> the Person Model) or should i extend the AbstractParty Model and use the
> "general" first name, last name way?
Didn't we cover this with you in yesterdays hangout session? Or did I
just go over the top with my amnesia spray again? ;)
My take on this is: The person model of the Party package is too
cumbersome to work with for most of the common projects.
I usually create a custom User model in my package extending
\TYPO3\Party\Domain\Model\AbstractParty and adding just the properties
that are relevant to the project *for the moment*.
I also started introducing some convenience methods so that you don't
have to interact with the (very low-level) account model in your MVC
code at all (credits to Christopher who showed me the light).
E.g. One party can be related to many accounts, but usually you want to
model a 1:1 relation.
Here an example convenience method to set the role of a user (if you
only have one role/user in your domain):
/**
* @param string $roleIdentifier
* @return void
*/
public function setRole($roleIdentifier) {
$role = $this->policyService->getRole($roleIdentifier);
$account = $this->getPrimaryAccount();
$account->setRoles(array($role));
}
BTW: I support Christians idea of moving AbstractParty to flow and make
the dependency to the party package optional.
--
Bastian Waidelich
--
Core Developer Team
TYPO3 .... inspiring people to share!
Get involved: typo3.org
More information about the Flow
mailing list