public static function MobileNumber::getMobileNumber in Mobile Number 8
Same name and namespace in other branches
- 2.0.x src/Element/MobileNumber.php \Drupal\mobile_number\Element\MobileNumber::getMobileNumber()
Get currently entered mobile number, given the form element.
Parameters
array $element: Mobile number form element.
bool $input_value: Whether to use the input value or the default value, TRUE = input value.
Return value
\libphonenumber\PhoneNumber|null Mobile number. Null if empty, or not valid, mobile number.
3 calls to MobileNumber::getMobileNumber()
- MobileNumber::isVerified in src/
Element/ MobileNumber.php - Gets verified status based on default value and verified numbers in session.
- MobileNumber::verifyAjax in src/
Element/ MobileNumber.php - Mobile number element ajax callback.
- MobileNumberWidget::errorElement in src/
Plugin/ Field/ FieldWidget/ MobileNumberWidget.php - Assigns a field-level validation error to the right widget sub-element.
File
- src/
Element/ MobileNumber.php, line 515
Class
- MobileNumber
- Provides a form input element for entering an email address.
Namespace
Drupal\mobile_number\ElementCode
public static function getMobileNumber($element, $input_value = TRUE) {
/** @var \Drupal\mobile_number\MobileNumberUtilInterface $util */
$util = \Drupal::service('mobile_number.util');
if ($input_value) {
$values = !empty($element['#value']['local_number']) ? $element['#value'] : [];
}
else {
$values = !empty($element['#default_value']['local_number']) ? $element['#default_value'] : [];
}
if ($values) {
return $util
->getMobileNumber($values['local_number'], $values['country']);
}
return NULL;
}