You are here

class SubscribeRoutes in SendinBlue 8

Same name and namespace in other branches
  1. 8.2 src/Routing/SubscribeRoutes.php \Drupal\sendinblue\Routing\SubscribeRoutes

Defines dynamic routes.

Hierarchy

Expanded class hierarchy of SubscribeRoutes

1 string reference to 'SubscribeRoutes'
sendinblue.services.yml in ./sendinblue.services.yml
sendinblue.services.yml
1 service uses SubscribeRoutes
sendinblue.routing in ./sendinblue.services.yml
Drupal\sendinblue\Routing\SubscribeRoutes

File

src/Routing/SubscribeRoutes.php, line 14

Namespace

Drupal\sendinblue\Routing
View source
class SubscribeRoutes implements ContainerInjectionInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * EntityModerationForm constructor.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('entity_type.manager'));
  }

  /**
   * {@inheritdoc}
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SubscribeRoutes::$entityTypeManager protected property The entity type manager.
SubscribeRoutes::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
SubscribeRoutes::routes public function
SubscribeRoutes::__construct public function EntityModerationForm constructor.