SalesforceMappedObjectAddLocalAction.php in Salesforce Suite 8.3
File
modules/salesforce_mapping/src/Plugin/Menu/LocalAction/SalesforceMappedObjectAddLocalAction.php
View source
<?php
namespace Drupal\salesforce_mapping\Plugin\Menu\LocalAction;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Menu\LocalActionDefault;
use Drupal\Core\Routing\RouteMatchInterface;
use Symfony\Component\HttpFoundation\Request;
class SalesforceMappedObjectAddLocalAction extends LocalActionDefault {
public function getTitle(Request $request = NULL) {
return 'Create Mapped Object';
}
public function getOptions(RouteMatchInterface $route_match) {
$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;
}
}