You are here

public function PhoneNumberVerification::deletePhoneVerificationByEntity in SMS Framework 8

Same name and namespace in other branches
  1. 2.x src/Provider/PhoneNumberVerification.php \Drupal\sms\Provider\PhoneNumberVerification::deletePhoneVerificationByEntity()
  2. 2.1.x src/Provider/PhoneNumberVerification.php \Drupal\sms\Provider\PhoneNumberVerification::deletePhoneVerificationByEntity()

Deletes phone number verifications for an entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Delete phone number verifications for this entity.

Overrides PhoneNumberVerificationInterface::deletePhoneVerificationByEntity

File

src/Provider/PhoneNumberVerification.php, line 226

Class

PhoneNumberVerification
Phone number verification provider.

Namespace

Drupal\sms\Provider

Code

public function deletePhoneVerificationByEntity(EntityInterface $entity) {

  // Check the entity uses phone numbers. To save on a SQL call, and to
  // prevent having to install phone number verification for SMS Framework
  // tests which delete entities. Which would otherwise error on non-existent
  // tables.
  try {
    $this
      ->getPhoneNumberSettingsForEntity($entity);
    $verification_entities = $this->phoneNumberVerificationStorage
      ->loadByProperties([
      'entity__target_id' => $entity
        ->id(),
      'entity__target_type' => $entity
        ->getEntityTypeId(),
    ]);
    $this->phoneNumberVerificationStorage
      ->delete($verification_entities);
  } catch (PhoneNumberSettingsException $e) {
  }
}