class ScheduledTransitionsRouteProvider in Scheduled Transitions 8
Same name and namespace in other branches
- 2.x src/Routing/ScheduledTransitionsRouteProvider.php \Drupal\scheduled_transitions\Routing\ScheduledTransitionsRouteProvider
Route provider for host entities of Scheduled Transitions.
Hierarchy
- class \Drupal\scheduled_transitions\Routing\ScheduledTransitionsRouteProvider implements EntityRouteProviderInterface
Expanded class hierarchy of ScheduledTransitionsRouteProvider
8 files declare their use of ScheduledTransitionsRouteProvider
- ScheduledTransitionEntityTest.php in tests/
src/ Functional/ ScheduledTransitionEntityTest.php - ScheduledTransitionEntityTransitionsFormTest.php in tests/
src/ Functional/ ScheduledTransitionEntityTransitionsFormTest.php - ScheduledTransitionModalFormTest.php in tests/
src/ Functional/ ScheduledTransitionModalFormTest.php - ScheduledTransitionsEntityHooks.php in src/
ScheduledTransitionsEntityHooks.php - ScheduledTransitionsLocalActions.php in src/
Plugin/ Derivative/ ScheduledTransitionsLocalActions.php
File
- src/
Routing/ ScheduledTransitionsRouteProvider.php, line 17
Namespace
Drupal\scheduled_transitions\RoutingView source
class ScheduledTransitionsRouteProvider implements EntityRouteProviderInterface {
/**
* Name of the link template for scheduled transitions form.
*
* Link template for scheduled transitions. This should not exist if the
* entity does not have a canonical template.
*/
public const LINK_TEMPLATE = 'scheduled_transitions';
public const FORM = 'scheduled_transitions_entity_form';
public const CANONICAL_PATH_SUFFIX = '/scheduled-transitions';
public const LINK_TEMPLATE_ADD = 'scheduled_transition_add';
public const FORM_ADD = 'scheduled_transitions_add_form';
public const CANONICAL_PATH_SUFFIX_ADD = '/scheduled-transitions/add';
public const ROUTE_ENTITY_TYPE = '_scheduled_transitions_entity_type';
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = new RouteCollection();
$entityTypeId = $entity_type
->id();
if ($entity_type
->hasLinkTemplate(static::LINK_TEMPLATE)) {
$path = $entity_type
->getLinkTemplate('canonical') . static::CANONICAL_PATH_SUFFIX;
$route = (new Route($path))
->addDefaults([
'_title' => 'Scheduled transitions',
'_entity_form' => $entityTypeId . '.' . static::FORM,
])
->setRequirement('_entity_access', $entityTypeId . '.' . Permissions::ENTITY_OPERATION_VIEW_TRANSITIONS)
->setRequirement(AccessCheck::ACCESS_CHECK_ID, 'TRUE')
->setOption('_admin_route', TRUE)
->setOption(static::ROUTE_ENTITY_TYPE, $entityTypeId)
->setOption('parameters', [
$entityTypeId => [
'type' => 'entity:' . $entityTypeId,
],
]);
$collection
->add(static::getScheduledTransitionRouteName($entity_type), $route);
}
if ($entity_type
->hasLinkTemplate(static::LINK_TEMPLATE_ADD)) {
$path = $entity_type
->getLinkTemplate('canonical') . static::CANONICAL_PATH_SUFFIX_ADD;
$route = (new Route($path))
->addDefaults([
'_title' => 'Add scheduled transition',
'_entity_form' => $entityTypeId . '.' . static::FORM_ADD,
])
->setRequirement('_entity_access', $entityTypeId . '.' . Permissions::ENTITY_OPERATION_ADD_TRANSITION)
->setRequirement(AccessCheck::ACCESS_CHECK_ID, 'TRUE')
->setOption('_admin_route', TRUE)
->setOption(static::ROUTE_ENTITY_TYPE, $entityTypeId)
->setOption('parameters', [
$entityTypeId => [
'type' => 'entity:' . $entityTypeId,
],
]);
$collection
->add(static::getScheduledTransitionAddRouteName($entity_type), $route);
}
return $collection;
}
/**
* Get the route name for scheduled transition form for an entity type..
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entityType
* An entity type.
*
* @return string
* The route name.
*/
public static function getScheduledTransitionRouteName(EntityTypeInterface $entityType) {
return sprintf('entity.%s.scheduled_transitions', $entityType
->id());
}
/**
* Get the route name for scheduled transition form for an entity type..
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entityType
* An entity type.
*
* @return string
* The route name.
*/
public static function getScheduledTransitionAddRouteName(EntityTypeInterface $entityType) {
return sprintf('entity.%s.scheduled_transition_add', $entityType
->id());
}
}