You are here

protected function RouteSubscriber::getFormRoute in Pardot Integration 2.x

Gets the version history route.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.

Return value

\Symfony\Component\Routing\Route|null The generated route, if available.

1 call to RouteSubscriber::getFormRoute()
RouteSubscriber::alterRoutes in src/Routing/RouteSubscriber.php
Alters existing routes for a specific collection.

File

src/Routing/RouteSubscriber.php, line 61

Class

RouteSubscriber
Subscriber for Devel routes.

Namespace

Drupal\pardot\Routing

Code

protected function getFormRoute(EntityTypeInterface $entity_type) {
  if ($route = new Route($entity_type
    ->getLinkTemplate('pardot-form-mapping'))) {
    $entity_type_id = $entity_type
      ->id();
    if ($entity_type_id === 'contact_form') {
      $method = 'renderContactFormMapping';
    }
    if ($entity_type_id === 'webform') {
      $method = 'renderWebformFormMapping';
    }
    if ($method) {
      $route
        ->setDefaults([
        //          '_title' => "Pardot Form Map: @contact_form",
        '_title' => "Pardot Form Map",
        '_controller' => '\\Drupal\\pardot\\Controller\\PardotFormMappingController::' . $method,
      ])
        ->setRequirement('_permission', 'administer pardot form map')
        ->setOption('parameters', [
        $entity_type_id => 'entity:' . $entity_type_id,
      ])
        ->setOption('_admin_route', TRUE);
      return $route;
    }
  }
}