Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,11 +15,11 @@ function telephone_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.telephone':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Telephone module allows you to create fields that contain telephone numbers. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":telephone_documentation">online documentation for the Telephone module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':telephone_documentation' => 'https://www.drupal.org/documentation/modules/telephone')) . '</p>';
|
||||
$output .= '<p>' . t('The Telephone module allows you to create fields that contain telephone numbers. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":telephone_documentation">online documentation for the Telephone module</a>.', [':field' => \Drupal::url('help.page', ['name' => 'field']), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#', ':telephone_documentation' => 'https://www.drupal.org/documentation/modules/telephone']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Managing and displaying telephone fields') . '</dt>';
|
||||
$output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the telephone field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the telephone field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', [':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', ['name' => 'field_ui']) : '#']) . '</dd>';
|
||||
$output .= '<dt>' . t('Displaying telephone numbers as links') . '</dt>';
|
||||
$output .= '<dd>' . t('Telephone numbers can be displayed as links with the scheme name <em>tel:</em> by choosing the <em>Telephone</em> display format on the <em>Manage display</em> page. Any spaces will be stripped out of the link text. This semantic markup improves the user experience on mobile and assistive technology devices.') . '</dd>';
|
||||
$output .= '</dl>';
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\telephone\Tests;
|
||||
namespace Drupal\Tests\telephone\Functional;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
|
@ -11,18 +11,18 @@ use Drupal\field\Entity\FieldStorageConfig;
|
|||
*
|
||||
* @group telephone
|
||||
*/
|
||||
class TelephoneFieldTest extends WebTestBase {
|
||||
class TelephoneFieldTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array(
|
||||
public static $modules = [
|
||||
'field',
|
||||
'node',
|
||||
'telephone'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* A user with permission to create articles.
|
||||
|
@ -34,8 +34,8 @@ class TelephoneFieldTest extends WebTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(array('type' => 'article'));
|
||||
$this->webUser = $this->drupalCreateUser(array('create article content', 'edit own article content'));
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
$this->webUser = $this->drupalCreateUser(['create article content', 'edit own article content']);
|
||||
$this->drupalLogin($this->webUser);
|
||||
}
|
||||
|
||||
|
@ -44,14 +44,14 @@ class TelephoneFieldTest extends WebTestBase {
|
|||
/**
|
||||
* Helper function for testTelephoneField().
|
||||
*/
|
||||
function testTelephoneField() {
|
||||
public function testTelephoneField() {
|
||||
|
||||
// Add the telephone field to the article content type.
|
||||
FieldStorageConfig::create(array(
|
||||
FieldStorageConfig::create([
|
||||
'field_name' => 'field_telephone',
|
||||
'entity_type' => 'node',
|
||||
'type' => 'telephone',
|
||||
))->save();
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'field_name' => 'field_telephone',
|
||||
'label' => 'Telephone Number',
|
||||
|
@ -60,19 +60,19 @@ class TelephoneFieldTest extends WebTestBase {
|
|||
])->save();
|
||||
|
||||
entity_get_form_display('node', 'article', 'default')
|
||||
->setComponent('field_telephone', array(
|
||||
->setComponent('field_telephone', [
|
||||
'type' => 'telephone_default',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'placeholder' => '123-456-7890',
|
||||
),
|
||||
))
|
||||
],
|
||||
])
|
||||
->save();
|
||||
|
||||
entity_get_display('node', 'article', 'default')
|
||||
->setComponent('field_telephone', array(
|
||||
->setComponent('field_telephone', [
|
||||
'type' => 'telephone_link',
|
||||
'weight' => 1,
|
||||
))
|
||||
])
|
||||
->save();
|
||||
|
||||
// Display creation form.
|
||||
|
@ -81,19 +81,19 @@ class TelephoneFieldTest extends WebTestBase {
|
|||
$this->assertRaw('placeholder="123-456-7890"');
|
||||
|
||||
// Test basic entry of telephone field.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'title[0][value]' => $this->randomMachineName(),
|
||||
'field_telephone[0][value]' => "123456789",
|
||||
);
|
||||
];
|
||||
|
||||
$this->drupalPostForm(NULL, $edit, t('Save'));
|
||||
$this->assertRaw('<a href="tel:123456789">', 'A telephone link is provided on the article node page.');
|
||||
|
||||
// Add number with a space in it. Need to ensure it is stripped on output.
|
||||
$edit = array(
|
||||
$edit = [
|
||||
'title[0][value]' => $this->randomMachineName(),
|
||||
'field_telephone[0][value]' => "1234 56789",
|
||||
);
|
||||
];
|
||||
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save'));
|
||||
$this->assertRaw('<a href="tel:123456789">', 'Telephone link is output with whitespace removed.');
|
|
@ -21,17 +21,17 @@ class TelephoneItemTest extends FieldKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('telephone');
|
||||
public static $modules = ['telephone'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create a telephone field storage and field for validation.
|
||||
FieldStorageConfig::create(array(
|
||||
FieldStorageConfig::create([
|
||||
'field_name' => 'field_test',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'telephone',
|
||||
))->save();
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_test',
|
||||
|
|
Reference in a new issue