/** * Vote for $action on $node not owned by $user * A user can act on someone else's node if he has the matching super role and the node is in his perimeter * * @param string $action * @param NodeInterface $node * @param UserInterface $user * * @return bool */ protected function voteForSomeoneElseSubject($action, $node, UserInterface $user) { $requiredRole = ContributionRoleInterface::NODE_CONTRIBUTOR; switch ($action) { case ContributionActionInterface::EDIT: $requiredRole = ContributionRoleInterface::NODE_SUPER_EDITOR; break; case ContributionActionInterface::DELETE: $requiredRole = ContributionRoleInterface::NODE_SUPER_SUPRESSOR; break; } return $user->hasRole($requiredRole) && $this->isSubjectInPerimeter($node->getPath(), $user, NodeInterface::ENTITY_TYPE); }
/** * @param UserInterface|string $user * * @return bool */ protected function isSuperAdmin($user = null) { return $user instanceof UserInterface && ($user->hasRole(ContributionRoleInterface::DEVELOPER) || $user->hasRole(ContributionRoleInterface::PLATFORM_ADMIN)); }