class RouteSubscriber in Salesforce Suite 8.4
Same name and namespace in other branches
- 5.0.x modules/salesforce_mapping_ui/src/Routing/RouteSubscriber.php \Drupal\salesforce_mapping_ui\Routing\RouteSubscriber
Listens to the dynamic route events.
Hierarchy
- class \Drupal\Core\Routing\RouteSubscriberBase implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
- class \Drupal\salesforce_mapping_ui\Routing\RouteSubscriber
Expanded class hierarchy of RouteSubscriber
1 string reference to 'RouteSubscriber'
- salesforce_mapping_ui.services.yml in modules/
salesforce_mapping_ui/ salesforce_mapping_ui.services.yml - modules/salesforce_mapping_ui/salesforce_mapping_ui.services.yml
1 service uses RouteSubscriber
- salesforce_mapping.route_subscriber in modules/
salesforce_mapping_ui/ salesforce_mapping_ui.services.yml - Drupal\salesforce_mapping_ui\Routing\RouteSubscriber
File
- modules/
salesforce_mapping_ui/ src/ Routing/ RouteSubscriber.php, line 14
Namespace
Drupal\salesforce_mapping_ui\RoutingView source
class RouteSubscriber extends RouteSubscriberBase {
/**
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The mappable entity types service.
*
* @var \Drupal\salesforce_mapping\SalesforceMappableEntityTypesInterface
*/
protected $mappable;
/**
* Constructs a new RouteSubscriber object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_manager) {
$this->entityTypeManager = $entity_manager;
}
/**
* {@inheritdoc}
*/
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);
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events = parent::getSubscribedEvents();
$events[RoutingEvents::ALTER] = [
'onAlterRoutes',
100,
];
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RouteSubscriber:: |
protected | property | The entity type manager service. | |
RouteSubscriber:: |
protected | property | The mappable entity types service. | |
RouteSubscriber:: |
protected | function |
Alters existing routes for a specific collection. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public static | function |
Returns an array of event names this subscriber wants to listen to. Overrides RouteSubscriberBase:: |
|
RouteSubscriber:: |
public | function | Constructs a new RouteSubscriber object. | |
RouteSubscriberBase:: |
public | function | Delegates the route altering to self::alterRoutes(). | 1 |