protected function DefaultHtmlRouteProvider::getDuplicateFormRoute in Entity API 8
Gets the duplicate-form 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 DefaultHtmlRouteProvider::getDuplicateFormRoute()
- DefaultHtmlRouteProvider::getRoutes in src/
Routing/ DefaultHtmlRouteProvider.php - Provides routes for entities.
File
- src/
Routing/ DefaultHtmlRouteProvider.php, line 51
Class
- DefaultHtmlRouteProvider
- Provides HTML routes for entities.
Namespace
Drupal\entity\RoutingCode
protected function getDuplicateFormRoute(EntityTypeInterface $entity_type) {
if ($entity_type
->hasLinkTemplate('duplicate-form')) {
$entity_type_id = $entity_type
->id();
$route = new Route($entity_type
->getLinkTemplate('duplicate-form'));
$route
->setDefaults([
'_controller' => EntityDuplicateController::class . '::form',
'_title_callback' => EntityDuplicateController::class . '::title',
'entity_type_id' => $entity_type_id,
])
->setRequirement('_entity_access', "{$entity_type_id}.duplicate")
->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;
}
}