public function publishRoleDraft($roleDraftId, $originalRoleId = null)
{
$query = $this->handler->createUpdateQuery();
$query->update($this->handler->quoteTable('ezrole'))->set($this->handler->quoteColumn('version'), $query->bindValue(Role::STATUS_DEFINED, null, \PDO::PARAM_INT));
// Draft was created from an existing role, so published role must get the original ID.
if ($originalRoleId !== null) {
$query->set($this->handler->quoteColumn('id'), $query->bindValue($originalRoleId, null, \PDO::PARAM_INT));
}
$query->where($query->expr->eq($this->handler->quoteColumn('id'), $query->bindValue($roleDraftId, 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(0, null, \PDO::PARAM_INT));
// Draft was created from an existing role, so published policies must get the original role ID.
if ($originalRoleId !== null) {
$policyQuery->set($this->handler->quoteColumn('role_id'), $policyQuery->bindValue($originalRoleId, null, \PDO::PARAM_INT));
}
$policyQuery->where($policyQuery->expr->eq($this->handler->quoteColumn('role_id'), $policyQuery->bindValue($roleDraftId, null, \PDO::PARAM_INT)));
$queryStatement = $policyQuery->prepare();
$queryStatement->execute();
}