You are here

public function SubscribeRoutes::routes in SendinBlue 8

Same name and namespace in other branches
  1. 8.2 src/Routing/SubscribeRoutes.php \Drupal\sendinblue\Routing\SubscribeRoutes::routes()
1 string reference to 'SubscribeRoutes::routes'
sendinblue.routing.yml in ./sendinblue.routing.yml
sendinblue.routing.yml

File

src/Routing/SubscribeRoutes.php, line 44

Class

SubscribeRoutes
Defines dynamic routes.

Namespace

Drupal\sendinblue\Routing

Code

public function routes() {
  $routes = [];
  $signups = $this->entityTypeManager
    ->getStorage(SendinblueManager::SENDINBLUE_SIGNUP_ENTITY)
    ->loadMultiple();
  foreach ($signups as $signup) {
    if ((int) $signup->mode->value == SendinblueManager::SENDINBLUE_SIGNUP_PAGE || (int) $signup->mode->value == SendinblueManager::SENDINBLUE_SIGNUP_BOTH) {
      $settings = !$signup->settings
        ->first() ? [] : $signup->settings
        ->first()
        ->getValue();
      $routes['sendinblue.subscribe.' . $signup->name->value] = new Route('/' . $settings['path'], [
        '_form' => '\\Drupal\\sendinblue\\Form\\SubscribeForm',
        '_title' => $signup->title->value,
        'mcsId' => $signup->mcsId->value,
      ], [
        '_permission' => 'access content',
      ]);
    }
  }
  return $routes;
}