class CouponRouteProvider in Commerce Core 8.2
Provides routes for the Coupon entity.
Hierarchy
- class \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider implements EntityHandlerInterface, EntityRouteProviderInterface
- class \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
- class \Drupal\commerce_promotion\CouponRouteProvider
- class \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider
Expanded class hierarchy of CouponRouteProvider
File
- modules/
promotion/ src/ CouponRouteProvider.php, line 11
Namespace
Drupal\commerce_promotionView source
class CouponRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
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;
}
}