You are here

public static function MobileNumber::isVerified in Mobile Number 8

Same name and namespace in other branches
  1. 2.0.x src/Element/MobileNumber.php \Drupal\mobile_number\Element\MobileNumber::isVerified()

Gets verified status based on default value and verified numbers in session.

Parameters

array $element: Form element.

Return value

bool True if verified, false otherwise.

3 calls to MobileNumber::isVerified()
MobileNumber::mobileNumberProcess in src/Element/MobileNumber.php
Mobile number element process callback.
MobileNumber::mobileNumberValidate in src/Element/MobileNumber.php
Mobile number element validate callback.
MobileNumber::verifyAjax in src/Element/MobileNumber.php
Mobile number element ajax callback.

File

src/Element/MobileNumber.php, line 541

Class

MobileNumber
Provides a form input element for entering an email address.

Namespace

Drupal\mobile_number\Element

Code

public static function isVerified($element) {

  /** @var \Drupal\mobile_number\MobileNumberUtilInterface $util */
  $util = \Drupal::service('mobile_number.util');
  $mobile_number = static::getMobileNumber($element);
  $default_mobile_number = static::getMobileNumber($element, FALSE);
  $verified = FALSE;
  if ($mobile_number) {
    $verified = ($default_mobile_number ? $util
      ->getCallableNumber($default_mobile_number) == $util
      ->getCallableNumber($mobile_number) : FALSE) && $element['#default_value']['verified'];
    $verified = $verified || $util
      ->isVerified($mobile_number);
  }
  return $verified;
}