You are here

protected function PromotionRouteProvider::getPromotionFormRoute in Commerce Core 8.2

Gets a promotion form route.

Parameters

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

string $operation: The 'operation' (e.g 'disable', 'enable').

Return value

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

1 call to PromotionRouteProvider::getPromotionFormRoute()
PromotionRouteProvider::getRoutes in modules/promotion/src/PromotionRouteProvider.php
Provides routes for entities.

File

modules/promotion/src/PromotionRouteProvider.php, line 40

Class

PromotionRouteProvider
Provides routes for the Promotion entity.

Namespace

Drupal\commerce_promotion

Code

protected function getPromotionFormRoute(EntityTypeInterface $entity_type, $operation) {
  if ($entity_type
    ->hasLinkTemplate($operation . '-form')) {
    $route = new Route($entity_type
      ->getLinkTemplate($operation . '-form'));
    $route
      ->addDefaults([
      '_entity_form' => "commerce_promotion.{$operation}",
      '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::title',
    ])
      ->setRequirement('_entity_access', 'commerce_promotion.update')
      ->setOption('parameters', [
      'commerce_promotion' => [
        'type' => 'entity:commerce_promotion',
      ],
    ])
      ->setRequirement('commerce_promotion', '\\d+')
      ->setOption('_admin_route', TRUE);
    return $route;
  }
}