class PromotionRouteProvider in Commerce Core 8.2
Provides routes for the Promotion entity.
Hierarchy
- class \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider implements EntityHandlerInterface, EntityRouteProviderInterface
- class \Drupal\entity\Routing\DefaultHtmlRouteProvider
- class \Drupal\entity\Routing\AdminHtmlRouteProvider
- class \Drupal\commerce_promotion\PromotionRouteProvider
- class \Drupal\entity\Routing\AdminHtmlRouteProvider
- class \Drupal\entity\Routing\DefaultHtmlRouteProvider
Expanded class hierarchy of PromotionRouteProvider
File
- modules/
promotion/ src/ PromotionRouteProvider.php, line 12
Namespace
Drupal\commerce_promotionView source
class PromotionRouteProvider extends AdminHtmlRouteProvider {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = parent::getRoutes($entity_type);
foreach ([
'enable',
'disable',
] as $operation) {
if ($form_route = $this
->getPromotionFormRoute($entity_type, $operation)) {
$collection
->add('entity.commerce_promotion.' . $operation . '_form', $form_route);
}
}
return $collection;
}
/**
* Gets a promotion form route.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
* @param string $operation
* The 'operation' (e.g 'disable', 'enable').
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
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;
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DefaultHtmlRouteProvider:: |
protected | property | The entity field manager. | |
DefaultHtmlRouteProvider:: |
protected | property | The entity type manager. | |
DefaultHtmlRouteProvider:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the add-form route. | 2 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the add page route. | 2 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the canonical route. | 3 |
DefaultHtmlRouteProvider:: |
protected | function |
Gets the collection route. Overrides DefaultHtmlRouteProvider:: |
|
DefaultHtmlRouteProvider:: |
protected | function | Gets the delete-form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Returns the delete multiple form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the duplicate-form route. | |
DefaultHtmlRouteProvider:: |
protected | function | Gets the edit-form route. | 1 |
DefaultHtmlRouteProvider:: |
protected | function | Gets the type of the ID key for a given entity type. | 1 |
DefaultHtmlRouteProvider:: |
public | function | Constructs a new DefaultHtmlRouteProvider. | 1 |
PromotionRouteProvider:: |
protected | function | Gets a promotion form route. | |
PromotionRouteProvider:: |
public | function |
Provides routes for entities. Overrides AdminHtmlRouteProvider:: |