private function MappedObjectController::getEntity in Salesforce Suite 5.0.x
Same name and namespace in other branches
- 8.4 modules/salesforce_mapping_ui/src/Controller/MappedObjectController.php \Drupal\salesforce_mapping_ui\Controller\MappedObjectController::getEntity()
Helper function to get entity from router path.
@TODO find a more specific exception class
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match service.
Return value
\Drupal\Core\Entity\EntityInterface The Drupal entity mapped by the given mapped object.
Throws
\Exception If an EntityInterface is not found at the given route.
1 call to MappedObjectController::getEntity()
- MappedObjectController::listing in modules/
salesforce_mapping_ui/ src/ Controller/ MappedObjectController.php - List mapped objects for the entity along the current route.
File
- modules/
salesforce_mapping_ui/ src/ Controller/ MappedObjectController.php, line 55
Class
- MappedObjectController
- Returns responses for devel module routes.
Namespace
Drupal\salesforce_mapping_ui\ControllerCode
private function getEntity(RouteMatchInterface $route_match) {
$parameter_name = $route_match
->getRouteObject()
->getOption('_salesforce_entity_type_id');
if (empty($parameter_name)) {
throw new \Exception('Entity type paramater not found.');
}
$entity = $route_match
->getParameter($parameter_name);
if (!$entity || !$entity instanceof EntityInterface) {
throw new \Exception('Entity is not of type EntityInterface');
}
return $entity;
}