class AccessTokenRouteProvider in Access unpublished 8
Contains routs for access tokens.
Hierarchy
- class \Drupal\access_unpublished\Routing\AccessTokenRouteProvider implements EntityRouteProviderInterface
Expanded class hierarchy of AccessTokenRouteProvider
File
- src/
Routing/ AccessTokenRouteProvider.php, line 14
Namespace
Drupal\access_unpublished\RoutingView source
class AccessTokenRouteProvider implements EntityRouteProviderInterface {
/**
* {@inheritdoc}
*/
public function getRoutes(EntityTypeInterface $entity_type) {
$collection = new RouteCollection();
$entity_type_id = $entity_type
->id();
if ($add_page_route = $this
->getRenewRoute($entity_type)) {
$collection
->add("entity.{$entity_type_id}.renew", $add_page_route);
}
if ($add_page_route = $this
->getDeleteRoute($entity_type)) {
$collection
->add("entity.{$entity_type_id}.delete", $add_page_route);
}
return $collection;
}
/**
* Gets the add page route.
*
* Built only for entity types that have bundles.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
*
* @return \Symfony\Component\Routing\Route|null
* The generated route, if available.
*/
protected function getRenewRoute(EntityTypeInterface $entity_type) {
$entity_type_id = $entity_type
->id();
$route = new Route($entity_type
->getLinkTemplate('renew'));
$route
->setDefault('_controller', AccessTokenController::class . '::renew')
->setRequirement('_permission', 'renew token')
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
return $route;
}
/**
* {@inheritdoc}
*/
protected function getDeleteRoute(EntityTypeInterface $entity_type) {
$entity_type_id = $entity_type
->id();
$route = new Route($entity_type
->getLinkTemplate('delete'));
$route
->setDefault('_controller', AccessTokenController::class . '::delete')
->setRequirement('_permission', 'delete token')
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
return $route;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccessTokenRouteProvider:: |
protected | function | ||
AccessTokenRouteProvider:: |
protected | function | Gets the add page route. | |
AccessTokenRouteProvider:: |
public | function |
Provides routes for entities. Overrides EntityRouteProviderInterface:: |