public function publishRoleDraft(APIRoleDraft $roleDraft)
    {
        if ($this->repository->hasAccess('role', 'update') !== true) {
            throw new UnauthorizedException('role', 'update');
        }

        try {
            $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id);
        } catch (APINotFoundException $e) {
            throw new BadStateException(
                '$roleDraft',
                'The role does not have a draft.',
                $e
            );
        }

        $this->repository->beginTransaction();
        try {
            $this->userHandler->publishRoleDraft($loadedRoleDraft->id);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
    }
public function publishRoleDraft(APIRoleDraft $roleDraft)
    {
        if ($this->repository->hasAccess('role', 'update') !== true) {
            throw new UnauthorizedException('role', 'update');
        }

        try {
            $loadedRoleDraft = $this->loadRoleDraft($roleDraft->id);
        } catch (APINotFoundException $e) {
            throw new BadStateException(
                '$roleDraft',
                'The role does not have a draft.',
                $e
            );
        }

        $this->repository->beginTransaction();
        try {
            $this->userHandler->publishRoleDraft($loadedRoleDraft->id);
            $this->repository->commit();
        } catch (Exception $e) {
            $this->repository->rollback();
            throw $e;
        }
    }
public function publishRoleDraft ( APIRoleDraft $ roleDraft ) { if ( $ this -> repository -> hasAccess ( 'role' , 'update' ) !== true ) { throw new UnauthorizedException ( 'role' , 'update' ) ; } try { $ loadedRoleDraft = $ this -> loadRoleDraft ( $ roleDraft -> id ) ; } catch ( APINotFoundException $ e ) { throw new BadStateException ( '$roleDraft' , 'The role does not have a draft.' , $ e ) ; } $ this -> repository -> beginTransaction ( ) ; try { $ this -> userHandler -> publishRoleDraft ( $ loadedRoleDraft -> id ) ; $ this -> repository -> commit ( ) ; } catch ( Exception $ e ) { $ this -> repository -> rollback ( ) ; throw $ e ; } }
Publishes a given RoleDraft.

@since 6.0

@throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to publish this RoleDraft
@throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the role draft cannot be loaded

@param \eZ\Publish\API\Repository\Values\User\RoleDraft $roleDraft
Publishes a given RoleDraft .