protected function CouponRouteProvider::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 AdminHtmlRouteProvider::getAddFormRoute
File
- modules/
promotion/ src/ CouponRouteProvider.php, line 16
Class
- CouponRouteProvider
- Provides routes for the Coupon entity.
Namespace
Drupal\commerce_promotionCode
protected function getAddFormRoute(EntityTypeInterface $entity_type) {
$route = parent::getAddFormRoute($entity_type);
$route
->setOption('parameters', [
'commerce_promotion' => [
'type' => 'entity:commerce_promotion',
],
]);
// Coupons can be created if the parent promotion can be updated.
$requirements = $route
->getRequirements();
unset($requirements['_entity_create_access']);
$requirements['_entity_access'] = 'commerce_promotion.update';
$route
->setRequirements($requirements);
return $route;
}