I am having some trouble working out how to use the orm to generate the correct query for access control. Any help would be appreciated.
I have a parent entity that has the team relationship on it.
This entity is linked to a child using a 'hasChildren' link
I want the child records to use the parent records team to determine team access.
I have added a "onlyTeam" select def but cant work out how to build the query.
What I have so far
I have a parent entity that has the team relationship on it.
This entity is linked to a child using a 'hasChildren' link
I want the child records to use the parent records team to determine team access.
I have added a "onlyTeam" select def but cant work out how to build the query.
What I have so far
PHP Code:
public function apply(QueryBuilder $queryBuilder): void
{
$queryBuilder->distinct();
$queryBuilder->leftJoin('parent', 'parentRecord');
$queryBuilder->leftJoin(
'teams', 'teamsAccess',
[
'parentRecord.id:'=> '???'
]
);
$orGroup = [
'teamsAccess.id' => $this->user->getTeamIdList()
];
$orGroup['parentRecord.assignedUserId'] = $this->user->id;
$orGroup['createdById'] = $this->user->id;
$orGroup['parentRecord.createdById'] = $this->user->id;
$queryBuilder->where([
'OR' => $orGroup,
]);
}
Comment