Chris@0: dateFormatter = $date_formatter; Chris@0: $this->redirectDestination = $redirect_destination; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { Chris@0: return new static( Chris@0: $entity_type, Chris@18: $container->get('entity_type.manager')->getStorage($entity_type->id()), Chris@0: $container->get('date.formatter'), Chris@0: $container->get('redirect.destination') Chris@0: ); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function buildHeader() { Chris@0: // Enable language column and filter if multiple languages are added. Chris@0: $header = [ Chris@0: 'title' => $this->t('Title'), Chris@0: 'type' => [ Chris@0: 'data' => $this->t('Content type'), Chris@0: 'class' => [RESPONSIVE_PRIORITY_MEDIUM], Chris@0: ], Chris@0: 'author' => [ Chris@0: 'data' => $this->t('Author'), Chris@0: 'class' => [RESPONSIVE_PRIORITY_LOW], Chris@0: ], Chris@0: 'status' => $this->t('Status'), Chris@0: 'changed' => [ Chris@0: 'data' => $this->t('Updated'), Chris@0: 'class' => [RESPONSIVE_PRIORITY_LOW], Chris@0: ], Chris@0: ]; Chris@0: if (\Drupal::languageManager()->isMultilingual()) { Chris@0: $header['language_name'] = [ Chris@0: 'data' => $this->t('Language'), Chris@0: 'class' => [RESPONSIVE_PRIORITY_LOW], Chris@0: ]; Chris@0: } Chris@0: return $header + parent::buildHeader(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function buildRow(EntityInterface $entity) { Chris@0: /** @var \Drupal\node\NodeInterface $entity */ Chris@0: $mark = [ Chris@0: '#theme' => 'mark', Chris@0: '#mark_type' => node_mark($entity->id(), $entity->getChangedTime()), Chris@0: ]; Chris@0: $langcode = $entity->language()->getId(); Chris@18: $uri = $entity->toUrl(); Chris@0: $options = $uri->getOptions(); Chris@0: $options += ($langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? ['language' => $languages[$langcode]] : []); Chris@0: $uri->setOptions($options); Chris@0: $row['title']['data'] = [ Chris@0: '#type' => 'link', Chris@0: '#title' => $entity->label(), Chris@0: '#suffix' => ' ' . \Drupal::service('renderer')->render($mark), Chris@0: '#url' => $uri, Chris@0: ]; Chris@0: $row['type'] = node_get_type_label($entity); Chris@0: $row['author']['data'] = [ Chris@0: '#theme' => 'username', Chris@0: '#account' => $entity->getOwner(), Chris@0: ]; Chris@0: $row['status'] = $entity->isPublished() ? $this->t('published') : $this->t('not published'); Chris@0: $row['changed'] = $this->dateFormatter->format($entity->getChangedTime(), 'short'); Chris@0: $language_manager = \Drupal::languageManager(); Chris@0: if ($language_manager->isMultilingual()) { Chris@0: $row['language_name'] = $language_manager->getLanguageName($langcode); Chris@0: } Chris@0: $row['operations']['data'] = $this->buildOperations($entity); Chris@0: return $row + parent::buildRow($entity); Chris@0: } Chris@0: Chris@0: }