You are here

public function CourierMessageController::channelList in Courier 8

Same name and namespace in other branches
  1. 2.x courier_message_composer/src/Controller/CourierMessageController.php \Drupal\courier_message_composer\Controller\CourierMessageController::channelList()

Return a list of links to channels.

1 string reference to 'CourierMessageController::channelList'
courier_message_composer.routing.yml in courier_message_composer/courier_message_composer.routing.yml
courier_message_composer/courier_message_composer.routing.yml

File

courier_message_composer/src/Controller/CourierMessageController.php, line 57

Class

CourierMessageController
Returns responses for CourierMessageController routes.

Namespace

Drupal\courier_message_composer\Controller

Code

public function channelList() {
  $render['channels'] = [
    '#title' => $this
      ->t('Channels'),
    '#theme' => 'item_list',
    '#items' => [],
  ];
  foreach (array_keys($this->identityChannelManager
    ->getChannels()) as $channel) {
    if ($this
      ->composeAnyIdentityForChannel($channel)) {
      $definition = $this->entityTypeManager
        ->getDefinition($channel);
      $item = [];
      $item[] = [
        '#type' => 'link',
        '#title' => $definition
          ->getLabel(),
        '#url' => Url::fromRoute('courier_message_composer.compose', [
          'courier_channel' => $channel,
        ]),
      ];
      $render['channels']['#items'][] = $item;
    }
  }
  return $render;
}