You are here

public function KanbanService::getEntityContentModerationEntities in Content Planner 8

Gets the Content Moderation Entities.

Parameters

string $workflow: The workflow ID.

array $filters: An array with the filters.

array $entities: An array with the entities.

Return value

\Drupal\content_moderation\Entity\ContentModerationState[] Returns an array with the content moderation states for the given workflow.

1 call to KanbanService::getEntityContentModerationEntities()
KanbanService::getEntityIdsFromContentModerationEntities in modules/content_kanban/src/KanbanService.php
Gets the entity IDs from Content Moderation entities.

File

modules/content_kanban/src/KanbanService.php, line 212

Class

KanbanService
Class KanbanService.

Namespace

Drupal\content_kanban

Code

public function getEntityContentModerationEntities($workflow, array $filters = [], array $entities = []) {
  $result = [];
  try {
    $query = $this->entityTypeManager
      ->getStorage('content_moderation_state')
      ->getQuery();
    if (!empty(array_keys($entities))) {
      $query
        ->condition('workflow', $workflow);
      $query
        ->condition('content_entity_type_id', array_keys($entities), 'in');
    }

    // Moderation state filter.
    if (array_key_exists('moderation_state', $filters) && $filters['moderation_state']) {
      $query
        ->condition('moderation_state', $filters['moderation_state']);
    }

    // User ID filter.
    if (array_key_exists('uid', $filters) && $filters['uid']) {
      $query
        ->condition('uid', $filters['uid']);
    }

    // User ID filter.
    $result = $query
      ->execute();
  } catch (InvalidPluginDefinitionException $e) {
    watchdog_exception('content_kanban', $e);
  } catch (PluginNotFoundException $e) {
    watchdog_exception('content_kanban', $e);
  }
  if ($result) {
    return ContentModerationState::loadMultiple($result);
  }
  return $result;
}