You are here

public function PhoneNumberSettings::rollback in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/Plugin/migrate/destination/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\destination\PhoneNumberSettings::rollback()
  2. 2.1.x src/Plugin/migrate/destination/PhoneNumberSettings.php \Drupal\sms\Plugin\migrate\destination\PhoneNumberSettings::rollback()

Delete the specified destination object from the target Drupal.

Parameters

array $destination_identifier: The ID of the destination object to delete.

Overrides EntityConfigBase::rollback

File

src/Plugin/migrate/destination/PhoneNumberSettings.php, line 39

Class

PhoneNumberSettings
Destination plugin for SMS phone number verifications.

Namespace

Drupal\sms\Plugin\migrate\destination

Code

public function rollback(array $destination_identifier) {

  /** @var \Drupal\sms\Entity\PhoneNumberSettingsInterface $phone_number_settings */
  $phone_number_settings = $this->storage
    ->load(reset($destination_identifier));
  $entity_type_id = $phone_number_settings
    ->getPhoneNumberEntityTypeId();
  $bundle = $phone_number_settings
    ->getPhoneNumberBundle();
  $field_name = $phone_number_settings
    ->getFieldName('phone_number');

  // Delete entity form display component.
  $entity_form_display = EntityFormDisplay::load($entity_type_id . '.' . $bundle . '.default');
  if ($entity_form_display) {
    $entity_form_display
      ->removeComponent($field_name);
  }

  // Delete the field storage and field instance.
  FieldStorageConfig::loadByName($entity_type_id, $field_name)
    ->delete();

  // Remove the phone number settings.
  parent::rollback($destination_identifier);
}