entityTypeManager = $entity_type_manager; } /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { return new static( $entity_type, $container->get('entity.manager')->getStorage($entity_type->id()), $container->get('date.formatter'), $container->get('redirect.destination'), $container->get('entity_type.manager') ); } /** * {@inheritdoc} */ public function load() { $revision_ids = $this->getEntityRevisionIds(); return $this->storage->loadMultipleRevisions($revision_ids); } /** * Loads entity revision IDs using a pager sorted by the entity revision ID. * * @return array * An array of entity revision IDs. */ protected function getEntityRevisionIds() { $query = $this->entityTypeManager->getStorage('content_moderation_state')->getAggregateQuery() ->aggregate('content_entity_id', 'MAX') ->groupBy('content_entity_revision_id') ->condition('content_entity_type_id', $this->entityTypeId) ->condition('moderation_state', 'published', '<>') ->sort('content_entity_revision_id', 'DESC'); // Only add the pager if a limit is specified. if ($this->limit) { $query->pager($this->limit); } $result = $query->execute(); return $result ? array_column($result, 'content_entity_revision_id') : []; } /** * {@inheritdoc} */ public function buildHeader() { $header = parent::buildHeader(); $header['status'] = $this->t('Moderation state'); return $header; } /** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { $row = parent::buildRow($entity); $row['status'] = $entity->moderation_state->value; return $row; } /** * {@inheritdoc} */ public function render() { $build = parent::render(); $build['table']['#empty'] = $this->t('There is no moderated @label yet. Only pending versions of @label, such as drafts, are listed here.', ['@label' => $this->entityType->getLabel()]); return $build; } }