You are here

public function PhoneNumberVerification::getPhoneVerificationByEntity in SMS Framework 2.x

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

Gets a phone number verification for an entity and phone number pair.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: An entity to get phone number verification.

string $phone_number: A phone number.

Return value

\Drupal\sms\Entity\PhoneNumberVerificationInterface|null The phone number verification for an entity and phone number pair.

Overrides PhoneNumberVerificationInterface::getPhoneVerificationByEntity

1 call to PhoneNumberVerification::getPhoneVerificationByEntity()
PhoneNumberVerification::updatePhoneVerificationByEntity in src/Provider/PhoneNumberVerification.php
Detect modifications to phone numbers on an entity.

File

src/Provider/PhoneNumberVerification.php, line 138

Class

PhoneNumberVerification
Phone number verification provider.

Namespace

Drupal\sms\Provider

Code

public function getPhoneVerificationByEntity(EntityInterface $entity, $phone_number) {
  $entities = $this->phoneNumberVerificationStorage
    ->loadByProperties([
    'entity__target_id' => $entity
      ->id(),
    'entity__target_type' => $entity
      ->getEntityTypeId(),
    'phone' => $phone_number,
  ]);
  return reset($entities);
}