Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -24,20 +24,20 @@ class TelephoneLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
return array(
return [
'title' => '',
) + parent::defaultSettings();
] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements['title'] = array(
$elements['title'] = [
'#type' => 'textfield',
'#title' => t('Title to replace basic numeric telephone number display'),
'#default_value' => $this->getSetting('title'),
);
];
return $elements;
}
@ -46,11 +46,11 @@ class TelephoneLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = array();
$summary = [];
$settings = $this->getSettings();
if (!empty($settings['title'])) {
$summary[] = t('Link using text: @title', array('@title' => $settings['title']));
$summary[] = t('Link using text: @title', ['@title' => $settings['title']]);
}
else {
$summary[] = t('Link using provided telephone number.');
@ -63,23 +63,23 @@ class TelephoneLinkFormatter extends FormatterBase {
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = array();
$element = [];
$title_setting = $this->getSetting('title');
foreach ($items as $delta => $item) {
// Render each element as link.
$element[$delta] = array(
$element[$delta] = [
'#type' => 'link',
// Use custom title if available, otherwise use the telephone number
// itself as title.
'#title' => $title_setting ?: $item->value,
// Prepend 'tel:' to the telephone number.
'#url' => Url::fromUri('tel:' . rawurlencode(preg_replace('/\s+/', '', $item->value))),
'#options' => array('external' => TRUE),
);
'#options' => ['external' => TRUE],
];
if (!empty($item->_attributes)) {
$element[$delta]['#options'] += array('attributes' => array());
$element[$delta]['#options'] += ['attributes' => []];
$element[$delta]['#options']['attributes'] += $item->_attributes;
// Unset field item attributes since they have been included in the
// formatter output and should not be rendered in the field template.

View file

@ -25,14 +25,14 @@ class TelephoneItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return array(
'columns' => array(
'value' => array(
return [
'columns' => [
'value' => [
'type' => 'varchar',
'length' => 256,
),
),
);
],
],
];
}
/**
@ -62,14 +62,14 @@ class TelephoneItem extends FieldItemBase {
$constraints = parent::getConstraints();
$max_length = 256;
$constraints[] = $constraint_manager->create('ComplexData', array(
'value' => array(
'Length' => array(
$constraints[] = $constraint_manager->create('ComplexData', [
'value' => [
'Length' => [
'max' => $max_length,
'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', array('%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length)),
)
),
));
'maxMessage' => t('%name: the telephone number may not be longer than @max characters.', ['%name' => $this->getFieldDefinition()->getLabel(), '@max' => $max_length]),
]
],
]);
return $constraints;
}

View file

@ -23,21 +23,21 @@ class TelephoneDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public static function defaultSettings() {
return array(
return [
'placeholder' => '',
) + parent::defaultSettings();
] + parent::defaultSettings();
}
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, FormStateInterface $form_state) {
$element['placeholder'] = array(
$element['placeholder'] = [
'#type' => 'textfield',
'#title' => t('Placeholder'),
'#default_value' => $this->getSetting('placeholder'),
'#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
);
];
return $element;
}
@ -45,11 +45,11 @@ class TelephoneDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public function settingsSummary() {
$summary = array();
$summary = [];
$placeholder = $this->getSetting('placeholder');
if (!empty($placeholder)) {
$summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
$summary[] = t('Placeholder: @placeholder', ['@placeholder' => $placeholder]);
}
else {
$summary[] = t('No placeholder');
@ -62,11 +62,11 @@ class TelephoneDefaultWidget extends WidgetBase {
* {@inheritdoc}
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$element['value'] = $element + array(
$element['value'] = $element + [
'#type' => 'tel',
'#default_value' => isset($items[$delta]->value) ? $items[$delta]->value : NULL,
'#placeholder' => $this->getSetting('placeholder'),
);
];
return $element;
}