eZ\Publish\Core\REST\Server\Controller\Role::assignRoleToUserGroup PHP Method

assignRoleToUserGroup() public method

Assigns role to user group.
public assignRoleToUserGroup ( $groupPath, Request $request ) : RoleAssignmentList
$groupPath
$request Symfony\Component\HttpFoundation\Request
return eZ\Publish\Core\REST\Server\Values\RoleAssignmentList
    public function assignRoleToUserGroup($groupPath, Request $request)
    {
        $roleAssignment = $this->inputDispatcher->parse(new Message(array('Content-Type' => $request->headers->get('Content-Type')), $request->getContent()));
        $groupLocationParts = explode('/', $groupPath);
        $groupLocation = $this->locationService->loadLocation(array_pop($groupLocationParts));
        $userGroup = $this->userService->loadUserGroup($groupLocation->contentId);
        $role = $this->roleService->loadRole($roleAssignment->roleId);
        try {
            $this->roleService->assignRoleToUserGroup($role, $userGroup, $roleAssignment->limitation);
        } catch (LimitationValidationException $e) {
            throw new BadRequestException($e->getMessage());
        }
        $roleAssignments = $this->roleService->getRoleAssignmentsForUserGroup($userGroup);
        return new Values\RoleAssignmentList($roleAssignments, $groupPath, true);
    }