public function putAction(Request $request, $id)
    {
        /** @var RoleInterface $role */
        $role = $this->getRoleRepository()->findRoleById($id);

        try {
            if (!$role) {
                throw new EntityNotFoundException($this->getRoleRepository()->getClassName(), $id);
            } else {
                $em = $this->getDoctrine()->getManager();

                $name = $request->get('name');

                $role->setName($name);
                $role->setSystem($request->get('system'));

                if (!$this->processPermissions($role, $request->get('permissions', []))) {
                    throw new RestException('Could not update dependencies!');
                }

                $securityTypeData = $request->get('securityType');
                if ($this->checkSecurityTypeData($securityTypeData)) {
                    $this->setSecurityType($role, $securityTypeData);
                } else {
                    $role->setSecurityType(null);
                }

                $em->flush();
                $view = $this->view($this->convertRole($role), 200);
            }
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (DoctrineUniqueConstraintViolationException $e) {
            throw new RoleNameAlreadyExistsException($name);
        } catch (RestException $re) {
            $view = $this->view($re->toArray(), 400);
        }

        return $this->handleView($view);
    }