Skip to content
Snippets Groups Projects
Commit e84a10f6 authored by Aaron Bauman's avatar Aaron Bauman Committed by Aaron Bauman
Browse files

Issue #3069784 by AaronBauman: Fix mapped object ui paths; webform submission path fix

parent e1165ade
No related branches found
No related tags found
No related merge requests found
......@@ -38,25 +38,12 @@ use Drupal\salesforce_mapping\Plugin\Field\ComputedItemList;
* "storage" = "Drupal\salesforce_mapping\MappedObjectStorage",
* "storage_schema" = "Drupal\salesforce_mapping\MappedObjectStorageSchema",
* "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",
* "views_data" = "Drupal\views\EntityViewsData",
* "list_builder" = "Drupal\salesforce_mapping\MappedObjectList",
* "form" = {
* "default" = "Drupal\salesforce_mapping\Form\MappedObjectForm",
* "add" = "Drupal\salesforce_mapping\Form\MappedObjectForm",
* "edit" = "Drupal\salesforce_mapping\Form\MappedObjectForm",
* "delete" = "Drupal\salesforce_mapping\Form\MappedObjectDeleteForm",
* },
* "views_data" = "Drupal\views\EntityViewsData",
* "access" = "Drupal\salesforce_mapping\MappedObjectAccessControlHandler",
* },
* base_table = "salesforce_mapped_object",
* revision_table = "salesforce_mapped_object_revision",
* admin_permission = "administer salesforce mapping",
* links = {
* "canonical" = "/admin/content/salesforce/{salesforce_mapped_object}",
* "add-form" = "/admin/content/salesforce/add",
* "edit-form" = "/admin/content/salesforce/{salesforce_mapped_object}/edit",
* "delete-form" = "/admin/content/salesforce/{salesforce_mapped_object}/delete"
* },
* entity_keys = {
* "id" = "id",
* "entity_id" = "drupal_entity__target_id",
......
......@@ -13,6 +13,9 @@ use Drupal\salesforce_mapping_ui\Form\SalesforceMappingDisableForm;
use Drupal\salesforce_mapping_ui\Form\SalesforceMappingDeleteForm;
use Drupal\salesforce_mapping_ui\Form\SalesforceMappingEnableForm;
use Drupal\salesforce_mapping_ui\Form\SalesforceMappingFieldsForm;
use Drupal\salesforce_mapping_ui\MappedObjectList;
use Drupal\salesforce_mapping_ui\Form\MappedObjectForm;
use Drupal\salesforce_mapping_ui\Form\MappedObjectDeleteForm;
/**
* Implements hook_entity_type_alter().
......@@ -25,10 +28,14 @@ function salesforce_mapping_ui_entity_type_alter(array &$entity_types) {
// mappable entity, and hide it for any entity types that don't have
// mappings.
foreach ($entity_types as $entity_type_id => $entity_type) {
if ($entity_type_id == 'salesforce_mapping' || $entity_type_id == 'salesforce_mapped_object') {
continue;
}
if ($entity_type->hasViewBuilderClass() && $entity_type->hasLinkTemplate('canonical')) {
$entity_type->setLinkTemplate('salesforce', "/$entity_type_id/{{$entity_type_id}}/salesforce");
}
}
// Set our UI classes for SalesforceMappingEntity.
$entity_types['salesforce_mapping']->setHandlerClass('list_builder', SalesforceMappingList::class);
$entity_types['salesforce_mapping']->setFormClass('add', SalesforceMappingAddForm::class);
......@@ -37,8 +44,20 @@ function salesforce_mapping_ui_entity_type_alter(array &$entity_types) {
$entity_types['salesforce_mapping']->setFormClass('delete', SalesforceMappingDeleteForm::class);
$entity_types['salesforce_mapping']->setFormClass('enable', SalesforceMappingEnableForm::class);
$entity_types['salesforce_mapping']->setFormClass('fields', SalesforceMappingFieldsForm::class);
$entity_types['salesforce_mapping']->setLinkTemplate('add-form', '/admin/structure/salesforce/mappings/add');
$entity_types['salesforce_mapping']->setLinkTemplate('edit-form', '/admin/structure/salesforce/mappings/manage/{salesforce_mapping}');
$entity_types['salesforce_mapping']->setLinkTemplate('delete-form', '/admin/structure/salesforce/mappings/manage/{salesforce_mapping}/delete');
// Set UI classes for MappedObject.
$entity_types['salesforce_mapped_object']->setHandlerClass('list_builder', MappedObjectList::class);
$entity_types['salesforce_mapped_object']->setFormClass('add', MappedObjectForm::class);
$entity_types['salesforce_mapped_object']->setFormClass('edit', MappedObjectForm::class);
$entity_types['salesforce_mapped_object']->setFormClass('delete', MappedObjectForm::class);
$entity_types['salesforce_mapped_object']->setFormClass('default', MappedObjectForm::class);
$entity_types['salesforce_mapped_object']->setLinkTemplate('add-form', '/admin/content/salesforce/add');
$entity_types['salesforce_mapped_object']->setLinkTemplate('edit-form', '/admin/content/salesforce/{salesforce_mapped_object}/edit');
$entity_types['salesforce_mapped_object']->setLinkTemplate('delete-form', '/admin/content/salesforce/{salesforce_mapped_object}/delete');
$entity_types['salesforce_mapped_object']->setLinkTemplate('canonical', '/admin/content/salesforce/{salesforce_mapped_object}');
}
/**
......
<?php
use Drupal\webform\Entity\WebformSubmission;
/**
* Implements hook_menu_local_tasks_alter().
*/
function salesforce_webform_menu_local_tasks_alter(&$data, $route_name) {
// ISSUE:
// Salesforce route does not use 'webform' parameter which throws an error.
// Some mandatory parameters are missing ("webform") to generate a URL for
// route "entity.webform_submission.salesforce"
//
// WORKAROUND:
// Make sure webform parameter is set for all routes.
//
// @see webform_menu_local_tasks_alter()
if ($route_name === 'entity.webform_submission.salesforce') {
foreach ($data['tabs'] as $tab_level) {
foreach ($tab_level as $tab) {
/** @var Drupal\Core\Url $url */
$url = $tab['#link']['url'];
$tab_route_name = $url->getRouteName();
$tab_route_parameters = $url->getRouteParameters();
if (strpos($tab_route_name, 'entity.webform_submission.salesforce') !== 0) {
$webform_submission = WebformSubmission::load($tab_route_parameters['webform_submission']);
$url->setRouteParameter('webform', $webform_submission->getWebform()->id());
}
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment