You are here

protected function ProductVariationRouteProvider::getAddFormRoute in Commerce Core 8.2

Gets the add-form route.

Parameters

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

Return value

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

Overrides DefaultHtmlRouteProvider::getAddFormRoute

File

modules/product/src/ProductVariationRouteProvider.php, line 18

Class

ProductVariationRouteProvider
Provides routes for the product variation entity.

Namespace

Drupal\commerce_product

Code

protected function getAddFormRoute(EntityTypeInterface $entity_type) {

  // The add-form route has no bundle argument because the bundle is selected
  // via the product ($product_type->getVariationTypeId()).
  $route = new Route($entity_type
    ->getLinkTemplate('add-form'));
  $route
    ->setDefaults([
    '_entity_form' => 'commerce_product_variation.add',
    'entity_type_id' => 'commerce_product_variation',
    '_title_callback' => ProductVariationController::class . '::addTitle',
  ])
    ->setRequirement('_product_variation_create_access', 'TRUE')
    ->setOption('parameters', [
    'commerce_product' => [
      'type' => 'entity:commerce_product',
    ],
  ])
    ->setOption('_admin_route', TRUE);
  return $route;
}