public function checkInAccount(User $user, Entity $entity) { $accountIdList = $user->getLinkMultipleIdList('accounts'); if (count($accountIdList)) { if (in_array($entity->id, $accountIdList)) { return true; } } return false; }
public function checkInTeam(User $user, Entity $entity) { $userTeamIdList = $user->getLinkMultipleIdList('teams'); if (!$entity->hasRelation('teams') || !$entity->hasAttribute('teamsIds')) { return false; } $entityTeamIdList = $entity->getLinkMultipleIdList('teams'); if (empty($entityTeamIdList)) { return false; } foreach ($userTeamIdList as $id) { if (in_array($id, $entityTeamIdList)) { return true; } } return false; }
public function checkInAccount(User $user, Entity $entity) { $accountIdList = $user->getLinkMultipleIdList('accounts'); if (count($accountIdList)) { if ($entity->hasAttribute('accountId')) { if (in_array($entity->get('accountId'), $accountIdList)) { return true; } } if ($entity->hasRelation('accounts')) { $repository = $this->getEntityManager()->getRepository($entity->getEntityType()); foreach ($accountIdList as $accountId) { if ($repository->isRelated($entity, 'accounts', $accountId)) { return true; } } } if ($entity->hasAttribute('parentId') && $entity->hasRelation('parent')) { if ($entity->get('parentType') === 'Account') { if (in_array($entity->get('parentId'), $accountIdList)) { return true; } } } } return false; }