/**
* @param User $user The User Entity
* @param Environment $environment optional The Environment Entity
* @param string|bool $modify optional ACL Permission Identifier or boolean flag whether it should check modify
* permissions or not.
* @return bool
*/
public function hasAccessPermissions($user, $environment = null, $modify = null)
{
$access = $environment && $this->envId == $environment->id;
if (is_bool($modify)) {
$modify = $modify ? Acl::PERM_FARMS_UPDATE : null;
}
if ($access) {
$superposition = $user->getAclRolesByEnvironment($environment->id);
$access = $superposition->isAllowed(Acl::RESOURCE_FARMS, $modify);
if (!$access && $this->hasUserTeamOwnership($user)) {
$access = $superposition->isAllowed(Acl::RESOURCE_TEAM_FARMS, $modify);
}
if (!$access && $this->ownerId && $user->id == $this->ownerId) {
$access = $superposition->isAllowed(Acl::RESOURCE_OWN_FARMS, $modify);
}
}
return $access;
}