public function SalesforceMappedObjectAddLocalAction::getOptions in Salesforce Suite 8.3
Returns options for rendering a link for the local action.
Parameters
\Drupal\Core\Routing\RouteMatchInterface $route_match: The current route match.
Return value
array An associative array of options.
Overrides LocalActionDefault::getOptions
File
- modules/
salesforce_mapping/ src/ Plugin/ Menu/ LocalAction/ SalesforceMappedObjectAddLocalAction.php, line 26
Class
- SalesforceMappedObjectAddLocalAction
- Local action for salesforce mapped objects.
Namespace
Drupal\salesforce_mapping\Plugin\Menu\LocalActionCode
public function getOptions(RouteMatchInterface $route_match) {
// If our local action is appearing contextually on an entity, provide
// contextual entity paramaters to the add form link.
$options = parent::getOptions($route_match);
$entity_type_id = $route_match
->getRouteObject()
->getOption('_salesforce_entity_type_id');
if (empty($entity_type_id)) {
return $options;
}
$entity = $route_match
->getParameter($entity_type_id);
if (!$entity || !$entity instanceof EntityInterface) {
return $options;
}
$options['query'] = [
'entity_type_id' => $entity_type_id,
'entity_id' => $entity
->id(),
];
return $options;
}