/** * Update role * * @throws \eZ\Publish\Core\Base\Exceptions\NotFoundException * * @param \eZ\Publish\SPI\Persistence\User\RoleUpdateStruct $role */ public function updateRole(RoleUpdateStruct $role) { $query = $this->handler->createUpdateQuery(); $query->update($this->handler->quoteTable('ezrole'))->set($this->handler->quoteColumn('name'), $query->bindValue($role->identifier))->where($query->expr->eq($this->handler->quoteColumn('id'), $query->bindValue($role->id, null, \PDO::PARAM_INT))); $statement = $query->prepare(); $statement->execute(); if ($statement->rowCount() < 1) { throw new NotFoundException('role', $role->id); } }
/** * Publish the specified role draft. * * @param mixed $roleId */ public function publishRoleDraft($roleId) { $query = $this->handler->createUpdateQuery(); $query->update($this->handler->quoteTable('ezrole'))->set($this->handler->quoteColumn('version'), $query->bindValue(Role::STATUS_DEFINED, null, \PDO::PARAM_INT))->where($query->expr->eq($this->handler->quoteColumn('id'), $query->bindValue($roleId, null, \PDO::PARAM_INT))); $statement = $query->prepare(); $statement->execute(); $policyQuery = $this->handler->createUpdateQuery(); $policyQuery->update($this->handler->quoteTable('ezpolicy'))->set($this->handler->quoteColumn('original_id'), $policyQuery->bindValue(Role::STATUS_DEFINED, null, \PDO::PARAM_INT))->where($policyQuery->expr->lAnd($policyQuery->expr->eq($this->handler->quoteColumn('role_id'), $policyQuery->bindValue($roleId, null, \PDO::PARAM_INT)), $policyQuery->expr->eq($this->handler->quoteColumn('original_id'), $policyQuery->bindValue(Role::STATUS_DRAFT, null, \PDO::PARAM_INT)))); $queryStatement = $policyQuery->prepare(); $queryStatement->execute(); }