Details on a given project role.

@param $projectId
@param $roleId
@return mixed
170115
public function findRole($projectId, $roleId)
    {
        return $this->apiClient->callEndpoint(sprintf('%s/%s/role/%s', self::ENDPOINT, $projectId, $roleId));
    }
435342
public function assignRole($roleId = null)
    {
        $roles = $this->roles;

        if (! $roles->contains($roleId)) {
            return $this->roles()->attach($roleId);
        }

        return false;
    }
25529
public function addPolicy($roleId, Request $request)
    {
        $createStruct = $this->inputDispatcher->parse(
            new Message(
                array('Content-Type' => $request->headers->get('Content-Type')),
                $request->getContent()
            )
        );

        try {
            // First try to treat $roleId as a role draft ID.
            $role = $this->roleService->addPolicyByRoleDraft(
                $this->roleService->loadRoleDraft($roleId),
                $createStruct
            );
        } catch (NotFoundException $e) {
            // Then try to treat $roleId as a role ID.
            $role = $this->roleService->addPolicy(
                $this->roleService->loadRole($roleId),
                $createStruct
            );
        } catch (LimitationValidationException $e) {
            throw new BadRequestException($e->getMessage());
        }

        return new Values\CreatedPolicy(
            array(
                'policy' => $this->getLastAddedPolicy($role),
            )
        );
    }
1226237
@RequestMapping(value = "projects/roles", method = RequestMethod.GET)
    public Resources<ProjectRole> getProjectRoles() {
        return Resources.of(
                rolesService.getProjectRoles(),
                uri(on(PermissionController.class).getProjectRoles())
        );
    }
21165
protected function selectProject($projectId = null, $host = null)
    {
        if (!empty($projectId)) {
            $this->project = $this->api()->getProject($projectId, $host);
            if (!$this->project) {
                throw new ConsoleInvalidArgumentException($this->getProjectNotFoundMessage($projectId));
            }

            $this->debug('Selected project: ' . $this->project->id);

            return $this->project;
        }

        $this->project = $this->getCurrentProject();
        if (!$this->project && isset($this->input) && $this->input->isInteractive()) {
            $projects = $this->api()->getProjects();
            if (count($projects) > 0 && count($projects) < 25) {
                $this->debug('No project specified: offering a choice...');
                $projectId = $this->offerProjectChoice($projects);

                return $this->selectProject($projectId);
            }
        }
        if (!$this->project) {
            throw new RootNotFoundException(
                "Could not determine the current project."
                . "\n\nSpecify it using --project, or go to a project directory."
            );
        }

        return $this->project;
    }
904367
public function svn($projectId)
    {
        $project = $this->fetchProject($projectId, 'svn');
        $branch = $this->getParam('branch', $project->getBranch());
        $commit = $this->getParam('commit');
        $commitMessage = $this->getParam('message');
        $committer = $this->getParam('committer');

        return $this->createBuild($project, $commit, $branch, $committer, $commitMessage);
    }
14009
public function assignRole($contentId, $roleId, array $limitation)
    {
        try {
            return $this->innerGateway->assignRole($contentId, $roleId, $limitation);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
614907
public function Index($RoleID = NULL) {
		$this->Permission('Garden.Settings.Manage');

      $this->AddSideMenu('dashboard/role');
      $this->AddJsFile('jquery.tablednd.js');
      $this->AddJsFile('jquery-ui.js');
      $this->Title(T('Roles & Permissions'));
      
      if (!$RoleID)
         $RoleData = $this->RoleModel->Get()->ResultArray();
      else {
         $Role = $this->RoleModel->GetID($RoleID);
         $RoleData = array($Role);
      }
      
      $this->SetData('Roles', $RoleData);
      $this->Render();
   }
133399
protected function getAclRule($roleId, $resourceId, $allowDeny = 'allow')
    {
        $rule = new AclRule();
        $rule->setRoleId($roleId);
        $rule->setRule($allowDeny);
        $rule->setResourceId($resourceId);
        $rule->setPrivilege('read');

        return $rule;
    }
285285
public function findSetting($roleId, $key)
    {
        $queryBuilder = $this->createQueryBuilder('s')
            ->join('s.role', 'r')
            ->where('r.id = :roleId')
            ->andWhere('s.key = :key')
            ->setParameters(['roleId' => $roleId, 'key' => $key]);

        try {
            return $queryBuilder->getQuery()->getSingleResult();
        } catch (NoResultException $e) {
            return;
        }
    }
210971
public function loadUsersAssignedToRole($roleId)
    {
        $role = $this->roleService->loadRole($roleId);
        $roleAssignments = $this->roleService->getRoleAssignments($role);

        $restUsers = array();

        foreach ($roleAssignments as $roleAssignment) {
            if ($roleAssignment instanceof UserRoleAssignment) {
                $restUsers[] = $this->buildRestUserObject($roleAssignment->getUser());
            }
        }

        return $restUsers;
    }
772311
public function getByProjectAndCommit($projectId, $commitId)
    {
        $query = 'SELECT * FROM `build` WHERE `project_id` = :project_id AND `commit_id` = :commit_id';
        $stmt = Database::getConnection('read')->prepare($query);
        $stmt->bindValue(':project_id', $projectId);
        $stmt->bindValue(':commit_id', $commitId);

        if ($stmt->execute()) {
            $res = $stmt->fetchAll(\PDO::FETCH_ASSOC);

            $map = function ($item) {
                return new Build($item);
            };

            $rtn = array_map($map, $res);

            return array('items' => $rtn, 'count' => count($rtn));
        } else {
            return array('items' => array(), 'count' => 0);
        }
    }
458213
public function publishRoleDraft($roleId)
    {
        try {
            // First try to load the draft for given role.
            $roleDraft = $this->roleService->loadRoleDraftByRoleId($roleId);
        } catch (NotFoundException $e) {
            // We might want a newly created role, so try to load it by its ID.
            // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
            $roleDraft = $this->roleService->loadRoleDraft($roleId);
        }

        $this->roleService->publishRoleDraft($roleDraft);

        $role = $this->roleService->loadRole($roleId);

        return new Values\PublishedRole(['role' => new Values\RestRole($role)]);
    }
1196568
public function loadRoleDraft($roleId)
    {
        try {
            // First try to load the draft for given role.
            return $this->roleService->loadRoleDraftByRoleId($roleId);
        } catch (NotFoundException $e) {
            // We might want a newly created role, so try to load it by its ID.
            // loadRoleDraft() might throw a NotFoundException (wrong $roleId). If so, let it bubble up.
            return $this->roleService->loadRoleDraft($roleId);
        }
    }
1103726
public function addPolicy($roleId, Policy $policy)
    {
        try {
            return $this->innerGateway->addPolicy($roleId, $policy);
        } catch (DBALException $e) {
            throw new RuntimeException('Database error', 0, $e);
        } catch (PDOException $e) {
            throw new RuntimeException('Database error', 0, $e);
        }
    }
915975
public function hasRoleById(int $roleId): bool
    {
        if (isset($this->roles[$roleId])) {
            return true;
        }

        return false;
    }
568821
def project_role(self, project, id):
        
        if isinstance(id, Number):
            id = "%s" % id
        return self._find_for_resource(Role, (project, id))