public function MobileNumberItem::getMobileNumber in Mobile Number 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Field/FieldType/MobileNumberItem.php \Drupal\mobile_number\Plugin\Field\FieldType\MobileNumberItem::getMobileNumber()
Get mobile number object of the current item.
Parameters
bool $throw_exception: Whether to throw mobile number validity exceptions.
Return value
\libphonenumber\PhoneNumber|null Mobile number object, or null if not valid.
3 calls to MobileNumberItem::getMobileNumber()
- MobileNumberItem::isUnique in src/
Plugin/ Field/ FieldType/ MobileNumberItem.php - Is mobile number unique within the entity/field. Will check verified numbers, only if specificed.
- MobileNumberItem::isVerified in src/
Plugin/ Field/ FieldType/ MobileNumberItem.php - Is the item's mobile number verified in the field's saved values or current session.
- MobileNumberItem::verify in src/
Plugin/ Field/ FieldType/ MobileNumberItem.php - Performs verification, assuming verification token and code were set. Adds to flood if failed. Will not attempt to verify if number is already verified.
File
- src/
Plugin/ Field/ FieldType/ MobileNumberItem.php, line 391
Class
- MobileNumberItem
- Plugin implementation of the 'mobile_number' field type.
Namespace
Drupal\mobile_number\Plugin\Field\FieldTypeCode
public function getMobileNumber($throw_exception = FALSE) {
/** @var \Drupal\mobile_number\MobileNumberUtilInterface $util */
$util = \Drupal::service('mobile_number.util');
$values = $this
->getValue();
$number = '';
$country = NULL;
if (!empty($values['country'])) {
if (!empty($values['local_number'])) {
$number = $values['local_number'];
}
$country = $values['country'];
}
if (!$number && !empty($values['value'])) {
$number = $values['value'];
}
if ($throw_exception) {
return $util
->testMobileNumber($number, $country);
}
else {
return $util
->getMobileNumber($number, $country);
}
}