You are here

public function SubscriptionListBuilder::render in Mailing List 8

Builds the entity listing as renderable array for table.html.twig.

@todo Add a link to add a new item to the #empty text.

Overrides EntityListBuilder::render

File

src/SubscriptionListBuilder.php, line 148

Class

SubscriptionListBuilder
Defines a class to build a listing of subscriptions.

Namespace

Drupal\mailing_list

Code

public function render() {
  $build = parent::render();

  // Anonymous users with no session started has no subscription access. We
  // return the anonymous subscription access form.
  if (!count($build['table']['#rows']) && $this->currentUser
    ->isAnonymous()) {
    return $this->formBuilder
      ->getForm('\\Drupal\\mailing_list\\Form\\AnonymousSubscriptionAccessForm');
  }
  $build['table']['#empty'] = $this
    ->t('No subscriptions found.');

  // Prevent search engines from indexing this subscriptions list and pages.
  $build['#attached']['html_head'][] = [
    [
      '#tag' => 'meta',
      '#attributes' => [
        'name' => 'robots',
        'content' => 'noindex,nofollow',
      ],
    ],
    'mailing_list',
  ];
  return $build;
}