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

Issue #3311403 by vladimir.krupin: Cannot delete MappedObject entity related to paragraph

parent fb9e3e5c
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
namespace Drupal\salesforce_mapping_ui\Form; namespace Drupal\salesforce_mapping_ui\Form;
use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Drupal\Core\Entity\ContentEntityConfirmFormBase;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\salesforce\Event\SalesforceNoticeEvent; use Drupal\salesforce\Event\SalesforceNoticeEvent;
use Drupal\salesforce\Event\SalesforceEvents; use Drupal\salesforce\Event\SalesforceEvents;
...@@ -44,8 +46,17 @@ class MappedObjectDeleteForm extends ContentEntityConfirmFormBase { ...@@ -44,8 +46,17 @@ class MappedObjectDeleteForm extends ContentEntityConfirmFormBase {
* Salesforce notvie level event which logs notice. * Salesforce notvie level event which logs notice.
*/ */
public function submitForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->setRedirectUrl(Url::fromRoute('entity.salesforce_mapped_object.list'));
$mapped_object = $this->getEntity(); $mapped_object = $this->getEntity();
$form_state->setRedirectUrl($mapped_object->getMappedEntity()->toUrl()); try {
$mapped_entity = $mapped_object->getMappedEntity();
if ($mapped_entity) {
$form_state->setRedirectUrl($mapped_entity->toUrl());
}
}
catch (UndefinedLinkTemplateException $e) {}
$message = 'MappedObject @sfid deleted.'; $message = 'MappedObject @sfid deleted.';
$args = ['@sfid' => $mapped_object->salesforce_id->value]; $args = ['@sfid' => $mapped_object->salesforce_id->value];
\Drupal::service('event_dispatcher')->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE); \Drupal::service('event_dispatcher')->dispatch(new SalesforceNoticeEvent(NULL, $message, $args), SalesforceEvents::NOTICE);
......
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