You are here

public function MappedObjectDeleteForm::submitForm in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 5.0.x modules/salesforce_mapping_ui/src/Form/MappedObjectDeleteForm.php \Drupal\salesforce_mapping_ui\Form\MappedObjectDeleteForm::submitForm()

Delete the entity and log the event. Event dispatcher service sends Salesforce notvie level event which logs notice.

Overrides ContentEntityForm::submitForm

File

modules/salesforce_mapping_ui/src/Form/MappedObjectDeleteForm.php, line 46

Class

MappedObjectDeleteForm
Provides a form for deleting a salesforce_mapped_oject entity.

Namespace

Drupal\salesforce_mapping_ui\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $mapped_object = $this
    ->getEntity();
  $form_state
    ->setRedirectUrl($mapped_object
    ->getMappedEntity()
    ->toUrl());
  $message = 'MappedObject @sfid deleted.';
  $args = [
    '@sfid' => $mapped_object->salesforce_id->value,
  ];
  \Drupal::service('event_dispatcher')
    ->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, $message, $args));
  $mapped_object
    ->delete();
}