You are here

protected function EasyEmailHtmlRouteProvider::getPreviewPlainRoute in Easy Email 8

Same name and namespace in other branches
  1. 2.0.x src/EasyEmailHtmlRouteProvider.php \Drupal\easy_email\EasyEmailHtmlRouteProvider::getPreviewPlainRoute()
1 call to EasyEmailHtmlRouteProvider::getPreviewPlainRoute()
EasyEmailHtmlRouteProvider::getRoutes in src/EasyEmailHtmlRouteProvider.php
Provides routes for entities.

File

src/EasyEmailHtmlRouteProvider.php, line 83

Class

EasyEmailHtmlRouteProvider
Provides routes for Email entities.

Namespace

Drupal\easy_email

Code

protected function getPreviewPlainRoute(EntityTypeInterface $entity_type) {
  if ($entity_type
    ->hasLinkTemplate('preview_plain')) {
    $entity_type_id = $entity_type
      ->id();
    $route = new Route($entity_type
      ->getLinkTemplate('preview_plain'));
    $route
      ->addDefaults([
      '_title' => "{$entity_type->getLabel()} preview",
      '_controller' => '\\Drupal\\easy_email\\Controller\\EasyEmailController::previewPlain',
    ])
      ->setRequirement('_entity_access', "{$entity_type_id}.view")
      ->setOption('parameters', [
      $entity_type_id => [
        'type' => 'entity:' . $entity_type_id,
      ],
    ]);

    // Entity types with serial IDs can specify this in their route
    // requirements, improving the matching process.
    if ($this
      ->getEntityTypeIdKeyType($entity_type) === 'integer') {
      $route
        ->setRequirement($entity_type_id, '\\d+');
    }
    return $route;
  }
}