public static function PhoneNumberSettings::postDelete in SMS Framework 2.1.x
Same name and namespace in other branches
- 8 src/Entity/PhoneNumberSettings.php \Drupal\sms\Entity\PhoneNumberSettings::postDelete()
- 2.x src/Entity/PhoneNumberSettings.php \Drupal\sms\Entity\PhoneNumberSettings::postDelete()
Acts on deleted entities before the delete hook is invoked.
Used after the entities are deleted but before invoking the delete hook.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
\Drupal\Core\Entity\EntityInterface[] $entities: An array of entities.
Overrides EntityBase::postDelete
File
- src/
Entity/ PhoneNumberSettings.php, line 212
Class
- PhoneNumberSettings
- Defines storage for an SMS Gateway instance.
Namespace
Drupal\sms\EntityCode
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// Delete associated phone number verifications.
// Does not remove phone number field values.
$verification_storage = \Drupal::entityTypeManager()
->getStorage('sms_phone_number_verification');
$verification_ids = [];
/** @var static $phone_number_settings */
foreach ($entities as $phone_number_settings) {
$verification_ids += $verification_storage
->getQuery()
->condition('entity__target_type', $phone_number_settings
->getPhoneNumberEntityTypeId())
->condition('bundle', $phone_number_settings
->getPhoneNumberBundle())
->execute();
}
$verification_storage
->delete($verification_storage
->loadMultiple($verification_ids));
}