publishRoleDraft() abstract public method

If the draft was created from an existing role, published version will take the original role ID.
abstract public publishRoleDraft ( mixed $roleDraftId, mixed | null $originalRoleId = null )
$roleDraftId mixed
$originalRoleId mixed | null ID of role the draft was created from. Will be null if the role draft was completely new.
 /**
  * Publish the specified role draft.
  *
  * @param mixed $roleId
  */
 public function publishRoleDraft($roleId)
 {
     try {
         return $this->innerGateway->publishRoleDraft($roleId);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }
Example #2
0
 /**
  * Publish the specified role draft.
  *
  * @param mixed $roleId
  */
 public function publishRoleDraft($roleId)
 {
     $roleDraft = $this->loadRole($roleId, Role::STATUS_DRAFT);
     try {
         $role = $this->loadRole($roleId);
         $roleAssignments = $this->loadRoleAssignmentsByRoleId($role->id);
         $this->deleteRole($role->id);
         foreach ($roleAssignments as $roleAssignment) {
             if (empty($roleAssignment->limitationIdentifier)) {
                 $this->assignRole($roleAssignment->contentId, $roleId);
             } else {
                 $this->assignRole($roleAssignment->contentId, $roleId, [$roleAssignment->limitationIdentifier => $roleAssignment->values]);
             }
         }
     } catch (NotFound $e) {
         // If no published role is found, no updates are necessary to it
     }
     $this->roleGateway->publishRoleDraft($roleDraft->id);
 }
Example #3
0
 /**
  * Publish the specified role draft.
  *
  * @param mixed $roleDraftId
  */
 public function publishRoleDraft($roleDraftId)
 {
     $roleDraft = $this->loadRole($roleDraftId, Role::STATUS_DRAFT);
     try {
         $originalRoleId = $roleDraft->originalId;
         $role = $this->loadRole($originalRoleId);
         $roleAssignments = $this->loadRoleAssignmentsByRoleId($role->id);
         $this->deleteRole($role->id);
         foreach ($roleAssignments as $roleAssignment) {
             if (empty($roleAssignment->limitationIdentifier)) {
                 $this->assignRole($roleAssignment->contentId, $originalRoleId);
             } else {
                 $this->assignRole($roleAssignment->contentId, $originalRoleId, [$roleAssignment->limitationIdentifier => $roleAssignment->values]);
             }
         }
         $this->roleGateway->publishRoleDraft($roleDraft->id, $role->id);
     } catch (NotFound $e) {
         // If no published role is found, only publishing is needed, without specifying original role ID as there is none.
         $this->roleGateway->publishRoleDraft($roleDraft->id);
     }
 }