protected function RouteSubscriber::alterRoutes in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping_ui/src/Routing/RouteSubscriber.php \Drupal\salesforce_mapping_ui\Routing\RouteSubscriber::alterRoutes()
Alters existing routes for a specific collection.
Parameters
\Symfony\Component\Routing\RouteCollection $collection: The route collection for adding routes.
Overrides RouteSubscriberBase::alterRoutes
File
- modules/
salesforce_mapping_ui/ src/ Routing/ RouteSubscriber.php, line 42
Class
- RouteSubscriber
- Listens to the dynamic route events.
Namespace
Drupal\salesforce_mapping_ui\RoutingCode
protected function alterRoutes(RouteCollection $collection) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
// If the entity didn't get a salesforce link template added by
// hook_entity_types_alter(), skip it.
if (!($path = $entity_type
->getLinkTemplate('salesforce'))) {
continue;
}
// Create the "listing" route to show all the mapped objects for this
// entity.
$route = new Route($path);
$route
->addDefaults([
'_controller' => "\\Drupal\\salesforce_mapping_ui\\Controller\\MappedObjectController::listing",
'_title' => "Salesforce mapped objects",
])
->addRequirements([
'_custom_access' => '\\Drupal\\salesforce_mapping_ui\\Controller\\MappedObjectController::access',
])
->setOption('_admin_route', TRUE)
->setOption('_salesforce_entity_type_id', $entity_type_id)
->setOption('parameters', [
$entity_type_id => [
'type' => 'entity:' . $entity_type_id,
],
]);
$collection
->add("entity.{$entity_type_id}.salesforce", $route);
}
}