@param int $id

@throws \InvalidArgumentException

@return Role
554269
public function setId($id)
    {
        if (!is_int($id) && !is_null($id)) {
            throw new \InvalidArgumentException(__CLASS__ . ' ' . __METHOD__ . ': Not an integer');
        }

        $this->id = $id;

        return $this;
    }
1330674
public function view($id = null) {
        $role = $this->Roles->get($id, [
            'contain' => ['Tasks', 'Users']
        ]);
        $this->set('role', $role);
        $this->set('_serialize', ['role']);
    }
391312
public static function updateRole($id, $role)
    {
        $activity = static::find()->where(['user_id' => $id])->limit(1)->one();
        if (empty($activity)) {
            Log::error('Cannot update user activity', $id, __METHOD__);
            return;
        }
        $activity->user_role = $role;
        if (!$activity->save()) {
            Log::error('Cannot update user activity', $id, __METHOD__);
            return;
        }
        Podium::getInstance()->podiumCache->delete('forum.lastactive');
    }
209235
public function setId($id = null)
        {
            if (null !== $id && !is_string($id) && !is_numeric($id)) {
                throw new Exception(
                        'Invalid argument: $id must be a string, number or null');
            }

            $this->_id = null === $id ? $id : (string) $id;

            return $this;
        }
1173924
public function getById(int $id)
	{
		return $this->setAuthorizer($this->getModel()->where('id', '=', $id)->first());
	}
508808
public function getGateway($id): GatewayInterface
    {
        $gateway = $this->_gateways[$id] ?? null;

        if ($gateway === null) {
            throw new InvalidArgumentException("Gateway: `$id` not exist!");
        } elseif (!$gateway instanceof GatewayInterface) {

            if (is_string($gateway)) {
                $gateway = ['class' => $gateway];
            }

            if (is_array($gateway)) {
                $gateway = ArrayHelper::merge($this->gatewayConfig, $gateway);
            }

            $gateway = $this->_gateways[$id] = Yii::createObject($gateway);
        }

        return $gateway;
    }
1104395
public function edit($id)
    {
        if (!$user = $this->userRepositoryInterface->getByIdWith($id, 'roles')) {
            Flash::error(trans('dashboard::dashboard.errors.user.found'));

            return redirect()->route('users.index');
        }

        $currentRoles = $user->getRoles()
                             ->lists('name');

        if (empty($currentRoles)) {
            $currentRoles = new Collection(['name' => 'Not Available']);
        }

        $currentRoles->sortBy('name');
        $currentRoles = implode(', ', $currentRoles->toArray());

        $roles = $this->roleRepositoryInterface->getAll()
                                               ->lists('name', 'slug');

        return $this->view('users.edit')
                    ->with(['user' => $user, 'currentRoles' => $currentRoles, 'roles' => $roles]);
    }
1205266
public function getSignature(int $id): Signature
    {
        if (isset($this->signatures[$id])) {
            return $this->signatures[$id];
        }

        throw new \InvalidArgumentException('The signature does not exist.');
    }
983269
public function setId(int $id): Field
    {
        Assert::greaterThan($id, 0);

        $this->id = $id;

        return $this;
    }
182305
public static function find($id)
    {
        $item = self::getAuthManager()->getRole($id);
        if ($item !== null) {
            return new self($item);
        }
        return null;
    }
565558
public function updateRole($id, array $content, array $options = [])
    {
        $data = [
            '_id' => $id,
            'body' => $content
        ];

        $response = $this->kuzzle->query(
            $this->buildQueryArgs('updateRole'),
            $data,
            $options
        );

        return new Role($this, $id, $response['result']['_source'], $response['result']['_meta']);
    }
48717
public function setRole($role_id)
    {
        if (!empty($role_id) && $this->policy === Rule::NOINHERIT)
            throw new Exception("Rule::NOINHERIT can not be used in combination with a role");

        if ($role_id instanceof Role)
        {
            $this->role = $role_id;
            $role_id = $role_id->getID();
        }
        elseif (!is_scalar($role_id))
            throw new Exception("Role-ID must be a Role or a scalar");

        if ($role_id !== $this->role_id)
        {
            $this->changed = true;
            $this->role_id = $role_id;
        }
    }
47285
public function actionAssign($id)
    {
        $post = Yii::$app->getRequest()->post();
        $action = $post['action'];
        $roles = $post['roles'];
        $manager = Yii::$app->getAuthManager();
        $parent = $this->type === Item::TYPE_ROLE ? $manager->getRole($id) : $manager->getPermission($id);

        $error = [];
        if ($action == 'assign') {
            foreach ($roles as $role) {
                $child = $manager->getPermission($role);
                if ($this->type === Item::TYPE_ROLE && $child === null) {
                    $child = $manager->getRole($role);
                }
                try {
                    $manager->addChild($parent, $child);
                } catch (\Exception $e) {
                    $error[] = $e->getMessage();
                }
            }
        } else {
            foreach ($roles as $role) {
                $child = $manager->getPermission($role);
                if ($this->type === Item::TYPE_ROLE && $child === null) {
                    $child = $manager->getRole($role);
                }
                try {
                    $manager->removeChild($parent, $child);
                } catch (\Exception $e) {
                    $error[] = $e->getMessage();
                }
            }
        }
        Helper::invalidate();
        Yii::$app->getResponse()->format = 'json';
        return $this->getItems($id);
    }
1237238
public static function find($id)
    {
        $item = Configs::authManager()->getRole($id);
        if ($item !== null) {
            return new self($item);
        }

        return null;
    }
635401
public function getAction($id)
    {
        $find = function($id) {
            /** @var RoleInterface $role */
            $role = $this->getRoleRepository()->findRoleById($id);

            return $this->convertRole($role);
        };

        $view = $this->responseGetById($id, $find);

        return $this->handleView($view);
    }
942177
public function setId(int $id): Folder
    {
        Assert::greaterThan($id, 0);

        $this->id = $id;

        return $this;
    }
635054
public function get($id)
    {
        if (!$this->has($id)) {
            throw new \InvalidArgumentException(sprintf('Configuration "%s" not found.', $id));
        }

        return $this->configurations[$id];
    }