public function ContactRouteProvider::getRoutes in Contact Storage 8
Provides routes for entities.
Parameters
\Drupal\Core\Entity\EntityTypeInterface $entity_type: The entity type
Return value
\Symfony\Component\Routing\RouteCollection|\Symfony\Component\Routing\Route[] Returns a route collection or an array of routes keyed by name, like route_callbacks inside 'routing.yml' files.
Overrides DefaultHtmlRouteProvider::getRoutes
File
- src/
ContactRouteProvider.php, line 17
Class
- ContactRouteProvider
- Provides routes for contact messages and contact forms.
Namespace
Drupal\contact_storageCode
public function getRoutes(EntityTypeInterface $entity_type) {
$route_collection = parent::getRoutes($entity_type);
if ($entity_type
->hasLinkTemplate('collection')) {
$route = (new Route($entity_type
->getLinkTemplate('collection')))
->addDefaults([
'_entity_list' => 'contact_message',
'_title' => 'Contact messages',
])
->addRequirements([
'_permission' => 'administer contact forms',
]);
$route_collection
->add('entity.' . $entity_type
->id() . '.collection', $route);
}
if ($entity_type
->hasLinkTemplate('clone-form')) {
$route = (new Route($entity_type
->getLinkTemplate('clone-form')))
->addDefaults([
'_entity_form' => 'contact_form.clone',
'_title' => 'Clone form',
])
->addRequirements([
'_entity_access' => 'contact_form.clone',
]);
$route_collection
->add('entity.' . $entity_type
->id() . '.clone_form', $route);
}
return $route_collection;
}