protected function InvoiceRouteProvider::getDownloadRoute in Commerce Invoice 8.2
Gets the download route.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type.
Return value
\Symfony\Component\Routing\Route|null The generated route, if available.
1 call to InvoiceRouteProvider::getDownloadRoute()
- InvoiceRouteProvider::getRoutes in src/
InvoiceRouteProvider.php - Provides routes for entities.
File
- src/
InvoiceRouteProvider.php, line 51
Class
- InvoiceRouteProvider
- Provides routes for the Invoice entity.
Namespace
Drupal\commerce_invoiceCode
protected function getDownloadRoute(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('download')) {
$entity_type_id = $entity_type
->id();
$route = new Route($entity_type
->getLinkTemplate('download'));
$route
->addDefaults([
'_controller' => '\\Drupal\\commerce_invoice\\Controller\\InvoiceController::download',
])
->setRequirement('_entity_access', "{$entity_type_id}.view")
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
// Entity types with serial IDs can specify this in their route
// requirements, improving the matching process.
if ($this
->getEntityTypeIdKeyType($entity_type) === 'integer') {
$route
->setRequirement($entity_type_id, '\\d+');
}
return $route;
}
}