public function MobileNumberWidget::settingsSummary in Mobile Number 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Field/FieldWidget/MobileNumberWidget.php \Drupal\mobile_number\Plugin\Field\FieldWidget\MobileNumberWidget::settingsSummary()
Returns a short summary for the current widget settings.
If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.
Return value
array A short summary of the widget settings.
Overrides WidgetBase::settingsSummary
File
- src/
Plugin/ Field/ FieldWidget/ MobileNumberWidget.php, line 124
Class
- MobileNumberWidget
- Plugin implementation of the 'mobile_number' widget.
Namespace
Drupal\mobile_number\Plugin\Field\FieldWidgetCode
public function settingsSummary() {
/** @var \Drupal\mobile_number\Element\MobileNumberUtilInterface $util */
$util = \Drupal::service('mobile_number.util');
$field_settings = $this
->getFieldSettings();
$field_country_validation = isset($field_settings['countries']);
$country_options = $util
->getCountryOptions();
$countries = $this
->getSetting('countries');
$countries = !$field_country_validation ? $countries ? implode(', ', $countries) : $this
->t('All') : NULL;
$result = [];
$result[] = $this
->t('Default country: @country', [
'@country' => $this
->getSetting('default_country'),
]);
if ($countries) {
$result[] = $this
->t('Allowed countries: @countries', [
'@countries' => $countries,
]);
}
$result[] = $this
->t('Number placeholder: @placeholder', [
'@placeholder' => $this
->getSetting('placeholder') !== NULL ? $this
->getSetting('placeholder') : 'Phone number',
]);
return $result;
}