You are here

function template_preprocess_subscription_add_list in Mailing List 8

Prepares variables for list of available mailing lists.

Default template: subscription-add-list.html.twig.

Parameters

array $variables: An associative array containing:

  • content: An array of mailing lists.

File

./mailing_list.module, line 35
Contains the Mailing list module.

Code

function template_preprocess_subscription_add_list(array &$variables) {
  $variables['lists'] = [];
  if (!empty($variables['content'])) {
    foreach ($variables['content'] as $list) {
      $variables['lists'][$list
        ->id()] = [
        'list' => $list
          ->id(),
        'label' => $list
          ->label(),
        'add_url' => Url::fromRoute('mailing_list.subscribe', [
          'mailing_list' => $list
            ->id(),
        ]),
        'description' => [
          '#markup' => $list
            ->getDescription(),
        ],
      ];
    }
  }
}