You are here

public function SubscriptionController::tab in Message Subscribe 8

Render the subscription management tab.

Parameters

\Drupal\user\UserInterface $user: The user account.

\Drupal\flag\FlagInterface $flag: The flag to display subscriptions for.

Return value

array A render array.

1 string reference to 'SubscriptionController::tab'
message_subscribe_ui.routing.yml in message_subscribe_ui/message_subscribe_ui.routing.yml
message_subscribe_ui/message_subscribe_ui.routing.yml

File

message_subscribe_ui/src/Controller/SubscriptionController.php, line 145

Class

SubscriptionController
Default controller for the message_subscribe_ui module.

Namespace

Drupal\message_subscribe_ui\Controller

Code

public function tab(UserInterface $user, FlagInterface $flag = NULL) {
  if (!$flag) {

    // We are inside /message-subscribe so get the first flag.
    $flags = $this->subscribers
      ->getFlags();
    $flag = reset($flags);
  }
  $view = $this
    ->getView($user, $flag);
  $result = $view
    ->preview();

  // Add cache tags for this flag and view.
  $result['#cache']['tags'] = $flag
    ->getCacheTags() + $view
    ->getCacheTags();
  return $result;
}