summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/path
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/path')
-rw-r--r--core/modules/path/path.api.php6
-rw-r--r--core/modules/path/path.module26
-rw-r--r--core/modules/path/src/Controller/PathController.php52
-rw-r--r--core/modules/path/src/Form/AddForm.php4
-rw-r--r--core/modules/path/src/Form/DeleteForm.php6
-rw-r--r--core/modules/path/src/Form/EditForm.php20
-rw-r--r--core/modules/path/src/Form/PathFilterForm.php28
-rw-r--r--core/modules/path/src/Form/PathFormBase.php26
-rw-r--r--core/modules/path/src/Plugin/Field/FieldType/PathItem.php4
-rw-r--r--core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php32
-rw-r--r--core/modules/path/src/Plugin/migrate/destination/UrlAlias.php4
-rw-r--r--core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php4
-rw-r--r--core/modules/path/src/Tests/PathAdminTest.php34
-rw-r--r--core/modules/path/src/Tests/PathNodeFormTest.php4
-rw-r--r--core/modules/path/src/Tests/PathTaxonomyTermTest.php14
-rw-r--r--core/modules/path/src/Tests/PathTestBase.php6
-rw-r--r--core/modules/path/tests/src/Functional/PathAliasTest.php40
-rw-r--r--core/modules/path/tests/src/Functional/PathLanguageTest.php32
-rw-r--r--core/modules/path/tests/src/Functional/PathLanguageUiTest.php14
-rw-r--r--core/modules/path/tests/src/Functional/PathTestBase.php6
-rw-r--r--core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php20
-rw-r--r--core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php2
-rw-r--r--core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php4
23 files changed, 194 insertions, 194 deletions
diff --git a/core/modules/path/path.api.php b/core/modules/path/path.api.php
index 04e1fb31679..df20b95e906 100644
--- a/core/modules/path/path.api.php
+++ b/core/modules/path/path.api.php
@@ -21,10 +21,10 @@
*/
function hook_path_insert($path) {
db_insert('mytable')
- ->fields(array(
+ ->fields([
'alias' => $path['alias'],
'pid' => $path['pid'],
- ))
+ ])
->execute();
}
@@ -40,7 +40,7 @@ function hook_path_insert($path) {
function hook_path_update($path) {
if ($path['alias'] != $path['original']['alias']) {
db_update('mytable')
- ->fields(array('alias' => $path['alias']))
+ ->fields(['alias' => $path['alias']])
->condition('pid', $path['pid'])
->execute();
}
diff --git a/core/modules/path/path.module b/core/modules/path/path.module
index 182c6a9dd09..a724b773d6e 100644
--- a/core/modules/path/path.module
+++ b/core/modules/path/path.module
@@ -18,13 +18,13 @@ function path_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.path':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
- $output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href=":pathauto">Pathauto</a>. For more information, see the <a href=":path">online documentation for the Path module</a>.', array(':path' => 'https://www.drupal.org/documentation/modules/path', ':pathauto' => 'https://www.drupal.org/project/pathauto')) . '</p>';
+ $output .= '<p>' . t('The Path module allows you to specify an alias, or custom URL, for any existing internal system path. Aliases should not be confused with URL redirects, which allow you to forward a changed or inactive URL to a new URL. In addition to making URLs more readable, aliases also help search engines index content more effectively. Multiple aliases may be used for a single internal system path. To automate the aliasing of paths, you can install the contributed module <a href=":pathauto">Pathauto</a>. For more information, see the <a href=":path">online documentation for the Path module</a>.', [':path' => 'https://www.drupal.org/documentation/modules/path', ':pathauto' => 'https://www.drupal.org/project/pathauto']) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Creating aliases') . '</dt>';
- $output .= '<dd>' . t('If you create or edit a taxonomy term you can add an alias (for example <em>music/jazz</em>) in the field "URL alias". When creating or editing content you can add an alias (for example <em>about-us/team</em>) under the section "URL path settings" in the field "URL alias". Aliases for any other path can be added through the page <a href=":aliases">URL aliases</a>. To add aliases a user needs the permission <a href=":permissions">Create and edit URL aliases</a>.', array(':aliases' => \Drupal::url('path.admin_overview'), ':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-path')))) . '</dd>';
+ $output .= '<dd>' . t('If you create or edit a taxonomy term you can add an alias (for example <em>music/jazz</em>) in the field "URL alias". When creating or editing content you can add an alias (for example <em>about-us/team</em>) under the section "URL path settings" in the field "URL alias". Aliases for any other path can be added through the page <a href=":aliases">URL aliases</a>. To add aliases a user needs the permission <a href=":permissions">Create and edit URL aliases</a>.', [':aliases' => \Drupal::url('path.admin_overview'), ':permissions' => \Drupal::url('user.admin_permissions', [], ['fragment' => 'module-path'])]) . '</dd>';
$output .= '<dt>' . t('Managing aliases') . '</dt>';
- $output .= '<dd>' . t('The Path module provides a way to search and view a <a href=":aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', array(':aliases' => \Drupal::url('path.admin_overview'))) . '</dd>';
+ $output .= '<dd>' . t('The Path module provides a way to search and view a <a href=":aliases">list of all aliases</a> that are in use on your website. Aliases can be added, edited and deleted through this list.', [':aliases' => \Drupal::url('path.admin_overview')]) . '</dd>';
$output .= '</dl>';
return $output;
@@ -41,20 +41,20 @@ function path_help($route_name, RouteMatchInterface $route_match) {
*/
function path_form_node_form_alter(&$form, FormStateInterface $form_state) {
$node = $form_state->getFormObject()->getEntity();
- $form['path_settings'] = array(
+ $form['path_settings'] = [
'#type' => 'details',
'#title' => t('URL path settings'),
'#open' => !empty($form['path']['widget'][0]['alias']['#value']),
'#group' => 'advanced',
'#access' => !empty($form['path']['#access']) && $node->hasField('path') && $node->get('path')->access('edit'),
- '#attributes' => array(
- 'class' => array('path-form'),
- ),
- '#attached' => array(
- 'library' => array('path/drupal.path'),
- ),
+ '#attributes' => [
+ 'class' => ['path-form'],
+ ],
+ '#attached' => [
+ 'library' => ['path/drupal.path'],
+ ],
'#weight' => 30,
- );
+ ];
$form['path']['#group'] = 'path_settings';
}
@@ -66,10 +66,10 @@ function path_entity_base_field_info(EntityTypeInterface $entity_type) {
$fields['path'] = BaseFieldDefinition::create('path')
->setLabel(t('URL alias'))
->setTranslatable(TRUE)
- ->setDisplayOptions('form', array(
+ ->setDisplayOptions('form', [
'type' => 'path',
'weight' => 30,
- ))
+ ])
->setDisplayConfigurable('form', TRUE)
->setComputed(TRUE);
diff --git a/core/modules/path/src/Controller/PathController.php b/core/modules/path/src/Controller/PathController.php
index 26b5d769476..51f88dd674e 100644
--- a/core/modules/path/src/Controller/PathController.php
+++ b/core/modules/path/src/Controller/PathController.php
@@ -69,63 +69,63 @@ class PathController extends ControllerBase {
// alias with a language.
$multilanguage = ($this->moduleHandler()->moduleExists('language') || $this->aliasStorage->languageAliasExists());
- $header = array();
- $header[] = array('data' => $this->t('Alias'), 'field' => 'alias', 'sort' => 'asc');
- $header[] = array('data' => $this->t('System'), 'field' => 'source');
+ $header = [];
+ $header[] = ['data' => $this->t('Alias'), 'field' => 'alias', 'sort' => 'asc'];
+ $header[] = ['data' => $this->t('System'), 'field' => 'source'];
if ($multilanguage) {
- $header[] = array('data' => $this->t('Language'), 'field' => 'langcode');
+ $header[] = ['data' => $this->t('Language'), 'field' => 'langcode'];
}
$header[] = $this->t('Operations');
- $rows = array();
+ $rows = [];
$destination = $this->getDestinationArray();
foreach ($this->aliasStorage->getAliasesForAdminListing($header, $keys) as $data) {
- $row = array();
+ $row = [];
// @todo Should Path module store leading slashes? See
// https://www.drupal.org/node/2430593.
- $row['data']['alias'] = $this->l(Unicode::truncate($data->alias, 50, FALSE, TRUE), Url::fromUserInput($data->source, array(
- 'attributes' => array('title' => $data->alias),
- )));
- $row['data']['source'] = $this->l(Unicode::truncate($data->source, 50, FALSE, TRUE), Url::fromUserInput($data->source, array(
+ $row['data']['alias'] = $this->l(Unicode::truncate($data->alias, 50, FALSE, TRUE), Url::fromUserInput($data->source, [
+ 'attributes' => ['title' => $data->alias],
+ ]));
+ $row['data']['source'] = $this->l(Unicode::truncate($data->source, 50, FALSE, TRUE), Url::fromUserInput($data->source, [
'alias' => TRUE,
- 'attributes' => array('title' => $data->source),
- )));
+ 'attributes' => ['title' => $data->source],
+ ]));
if ($multilanguage) {
$row['data']['language_name'] = $this->languageManager()->getLanguageName($data->langcode);
}
- $operations = array();
- $operations['edit'] = array(
+ $operations = [];
+ $operations['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('path.admin_edit', ['pid' => $data->pid], ['query' => $destination]),
- );
- $operations['delete'] = array(
+ ];
+ $operations['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('path.delete', ['pid' => $data->pid], ['query' => $destination]),
- );
- $row['data']['operations'] = array(
- 'data' => array(
+ ];
+ $row['data']['operations'] = [
+ 'data' => [
'#type' => 'operations',
'#links' => $operations,
- ),
- );
+ ],
+ ];
// If the system path maps to a different URL alias, highlight this table
// row to let the user know of old aliases.
if ($data->alias != $this->aliasManager->getAliasByPath($data->source, $data->langcode)) {
- $row['class'] = array('warning');
+ $row['class'] = ['warning'];
}
$rows[] = $row;
}
- $build['path_table'] = array(
+ $build['path_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
- '#empty' => $this->t('No URL aliases available. <a href=":link">Add URL alias</a>.', array(':link' => $this->url('path.admin_add'))),
- );
- $build['path_pager'] = array('#type' => 'pager');
+ '#empty' => $this->t('No URL aliases available. <a href=":link">Add URL alias</a>.', [':link' => $this->url('path.admin_add')]),
+ ];
+ $build['path_pager'] = ['#type' => 'pager'];
return $build;
}
diff --git a/core/modules/path/src/Form/AddForm.php b/core/modules/path/src/Form/AddForm.php
index 5b7acef8bb2..8f8d4f6b143 100644
--- a/core/modules/path/src/Form/AddForm.php
+++ b/core/modules/path/src/Form/AddForm.php
@@ -20,12 +20,12 @@ class AddForm extends PathFormBase {
* {@inheritdoc}
*/
protected function buildPath($pid) {
- return array(
+ return [
'source' => '',
'alias' => '',
'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
'pid' => NULL,
- );
+ ];
}
}
diff --git a/core/modules/path/src/Form/DeleteForm.php b/core/modules/path/src/Form/DeleteForm.php
index 45cd9a28031..b28fdc04eda 100644
--- a/core/modules/path/src/Form/DeleteForm.php
+++ b/core/modules/path/src/Form/DeleteForm.php
@@ -57,7 +57,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function getQuestion() {
- return t('Are you sure you want to delete path alias %title?', array('%title' => $this->pathAlias['alias']));
+ return t('Are you sure you want to delete path alias %title?', ['%title' => $this->pathAlias['alias']]);
}
/**
@@ -71,7 +71,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
- $this->pathAlias = $this->aliasStorage->load(array('pid' => $pid));
+ $this->pathAlias = $this->aliasStorage->load(['pid' => $pid]);
$form = parent::buildForm($form, $form_state);
@@ -82,7 +82,7 @@ class DeleteForm extends ConfirmFormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $this->aliasStorage->delete(array('pid' => $this->pathAlias['pid']));
+ $this->aliasStorage->delete(['pid' => $this->pathAlias['pid']]);
$form_state->setRedirect('path.admin_overview');
}
diff --git a/core/modules/path/src/Form/EditForm.php b/core/modules/path/src/Form/EditForm.php
index aeb285dad22..7d4a3693022 100644
--- a/core/modules/path/src/Form/EditForm.php
+++ b/core/modules/path/src/Form/EditForm.php
@@ -21,7 +21,7 @@ class EditForm extends PathFormBase {
* {@inheritdoc}
*/
protected function buildPath($pid) {
- return $this->aliasStorage->load(array('pid' => $pid));
+ return $this->aliasStorage->load(['pid' => $pid]);
}
/**
@@ -31,27 +31,27 @@ class EditForm extends PathFormBase {
$form = parent::buildForm($form, $form_state, $pid);
$form['#title'] = $this->path['alias'];
- $form['pid'] = array(
+ $form['pid'] = [
'#type' => 'hidden',
'#value' => $this->path['pid'],
- );
+ ];
- $url = new Url('path.delete', array(
+ $url = new Url('path.delete', [
'pid' => $this->path['pid'],
- ));
+ ]);
if ($this->getRequest()->query->has('destination')) {
$url->setOption('query', $this->getDestinationArray());
}
- $form['actions']['delete'] = array(
+ $form['actions']['delete'] = [
'#type' => 'link',
'#title' => $this->t('Delete'),
'#url' => $url,
- '#attributes' => array(
- 'class' => array('button', 'button--danger'),
- ),
- );
+ '#attributes' => [
+ 'class' => ['button', 'button--danger'],
+ ],
+ ];
return $form;
}
diff --git a/core/modules/path/src/Form/PathFilterForm.php b/core/modules/path/src/Form/PathFilterForm.php
index 6ac15855aa5..f7829061ecb 100644
--- a/core/modules/path/src/Form/PathFilterForm.php
+++ b/core/modules/path/src/Form/PathFilterForm.php
@@ -21,31 +21,31 @@ class PathFilterForm extends FormBase {
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state, $keys = NULL) {
- $form['#attributes'] = array('class' => array('search-form'));
- $form['basic'] = array(
+ $form['#attributes'] = ['class' => ['search-form']];
+ $form['basic'] = [
'#type' => 'details',
'#title' => $this->t('Filter aliases'),
'#open' => TRUE,
- '#attributes' => array('class' => array('container-inline')),
- );
- $form['basic']['filter'] = array(
+ '#attributes' => ['class' => ['container-inline']],
+ ];
+ $form['basic']['filter'] = [
'#type' => 'search',
'#title' => 'Path alias',
'#title_display' => 'invisible',
'#default_value' => $keys,
'#maxlength' => 128,
'#size' => 25,
- );
- $form['basic']['submit'] = array(
+ ];
+ $form['basic']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Filter'),
- );
+ ];
if ($keys) {
- $form['basic']['reset'] = array(
+ $form['basic']['reset'] = [
'#type' => 'submit',
'#value' => $this->t('Reset'),
- '#submit' => array('::resetForm'),
- );
+ '#submit' => ['::resetForm'],
+ ];
}
return $form;
}
@@ -54,9 +54,9 @@ class PathFilterForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- $form_state->setRedirect('path.admin_overview_filter', array(), array(
- 'query' => array('search' => trim($form_state->getValue('filter'))),
- ));
+ $form_state->setRedirect('path.admin_overview_filter', [], [
+ 'query' => ['search' => trim($form_state->getValue('filter'))],
+ ]);
}
/**
diff --git a/core/modules/path/src/Form/PathFormBase.php b/core/modules/path/src/Form/PathFormBase.php
index dba3a3fa5d7..884d24fb8ac 100644
--- a/core/modules/path/src/Form/PathFormBase.php
+++ b/core/modules/path/src/Form/PathFormBase.php
@@ -95,7 +95,7 @@ abstract class PathFormBase extends FormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state, $pid = NULL) {
$this->path = $this->buildPath($pid);
- $form['source'] = array(
+ $form['source'] = [
'#type' => 'textfield',
'#title' => $this->t('Existing system path'),
'#default_value' => $this->path['source'],
@@ -104,8 +104,8 @@ abstract class PathFormBase extends FormBase {
'#description' => $this->t('Specify the existing path you wish to alias. For example: /node/28, /forum/1, /taxonomy/term/1.'),
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
'#required' => TRUE,
- );
- $form['alias'] = array(
+ ];
+ $form['alias'] = [
'#type' => 'textfield',
'#title' => $this->t('Path alias'),
'#default_value' => $this->path['alias'],
@@ -114,17 +114,17 @@ abstract class PathFormBase extends FormBase {
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),
'#field_prefix' => $this->requestContext->getCompleteBaseUrl(),
'#required' => TRUE,
- );
+ ];
// A hidden value unless language.module is enabled.
if (\Drupal::moduleHandler()->moduleExists('language')) {
$languages = \Drupal::languageManager()->getLanguages();
- $language_options = array();
+ $language_options = [];
foreach ($languages as $langcode => $language) {
$language_options[$langcode] = $language->getName();
}
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'select',
'#title' => $this->t('Language'),
'#options' => $language_options,
@@ -133,21 +133,21 @@ abstract class PathFormBase extends FormBase {
'#default_value' => $this->path['langcode'],
'#weight' => -10,
'#description' => $this->t('A path alias set for a specific language will always be used when displaying this page in that language, and takes precedence over path aliases set as <em>- None -</em>.'),
- );
+ ];
}
else {
- $form['langcode'] = array(
+ $form['langcode'] = [
'#type' => 'value',
'#value' => $this->path['langcode']
- );
+ ];
}
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Save'),
'#button_type' => 'primary',
- );
+ ];
return $form;
}
@@ -193,7 +193,7 @@ abstract class PathFormBase extends FormBase {
if (!$this->pathValidator->isValid(trim($source, '/'))) {
- $form_state->setErrorByName('source', t("The path '@link_path' is either invalid or you do not have access to it.", array('@link_path' => $source)));
+ $form_state->setErrorByName('source', t("The path '@link_path' is either invalid or you do not have access to it.", ['@link_path' => $source]));
}
}
diff --git a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php
index 239588fd515..4d8da7a8ad7 100644
--- a/core/modules/path/src/Plugin/Field/FieldType/PathItem.php
+++ b/core/modules/path/src/Plugin/Field/FieldType/PathItem.php
@@ -37,7 +37,7 @@ class PathItem extends FieldItemBase {
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
- return array();
+ return [];
}
/**
@@ -62,7 +62,7 @@ class PathItem extends FieldItemBase {
else {
// Delete old alias if user erased it.
if ($this->pid && !$this->alias) {
- \Drupal::service('path.alias_storage')->delete(array('pid' => $this->pid));
+ \Drupal::service('path.alias_storage')->delete(['pid' => $this->pid]);
}
// Only save a non-empty alias.
elseif ($this->alias) {
diff --git a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
index 366db885a69..b31af4694b7 100644
--- a/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
+++ b/core/modules/path/src/Plugin/Field/FieldWidget/PathWidget.php
@@ -26,47 +26,47 @@ class PathWidget extends WidgetBase {
*/
public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
$entity = $items->getEntity();
- $path = array();
+ $path = [];
if (!$entity->isNew()) {
- $conditions = array('source' => '/' . $entity->urlInfo()->getInternalPath());
+ $conditions = ['source' => '/' . $entity->urlInfo()->getInternalPath()];
if ($items->getLangcode() != LanguageInterface::LANGCODE_NOT_SPECIFIED) {
$conditions['langcode'] = $items->getLangcode();
}
$path = \Drupal::service('path.alias_storage')->load($conditions);
if ($path === FALSE) {
- $path = array();
+ $path = [];
}
}
- $path += array(
+ $path += [
'pid' => NULL,
'source' => !$entity->isNew() ? '/' . $entity->urlInfo()->getInternalPath() : NULL,
'alias' => '',
'langcode' => $items->getLangcode(),
- );
+ ];
- $element += array(
- '#element_validate' => array(array(get_class($this), 'validateFormElement')),
- );
- $element['alias'] = array(
+ $element += [
+ '#element_validate' => [[get_class($this), 'validateFormElement']],
+ ];
+ $element['alias'] = [
'#type' => 'textfield',
'#title' => $element['#title'],
'#default_value' => $path['alias'],
'#required' => $element['#required'],
'#maxlength' => 255,
'#description' => $this->t('Specify an alternative path by which this data can be accessed. For example, type "/about" when writing an about page.'),
- );
- $element['pid'] = array(
+ ];
+ $element['pid'] = [
'#type' => 'value',
'#value' => $path['pid'],
- );
- $element['source'] = array(
+ ];
+ $element['source'] = [
'#type' => 'value',
'#value' => $path['source'],
- );
- $element['langcode'] = array(
+ ];
+ $element['langcode'] = [
'#type' => 'value',
'#value' => $path['langcode'],
- );
+ ];
return $element;
}
diff --git a/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php b/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php
index a71bcc9cbba..385ee4ba465 100644
--- a/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php
+++ b/core/modules/path/src/Plugin/migrate/destination/UrlAlias.php
@@ -58,7 +58,7 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$source = $row->getDestinationProperty('source');
$alias = $row->getDestinationProperty('alias');
$langcode = $row->getDestinationProperty('langcode');
@@ -75,7 +75,7 @@ class UrlAlias extends DestinationBase implements ContainerFactoryPluginInterfac
$path = $this->aliasStorage->save($source, $alias, $langcode, $pid);
- return array($path['pid']);
+ return [$path['pid']];
}
/**
diff --git a/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php b/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
index 3529ce28330..7714cbd1c4f 100644
--- a/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
+++ b/core/modules/path/src/Plugin/migrate/source/UrlAliasBase.php
@@ -24,10 +24,10 @@ abstract class UrlAliasBase extends DrupalSqlBase {
* {@inheritdoc}
*/
public function fields() {
- return array(
+ return [
'pid' => $this->t('The numeric identifier of the path alias.'),
'language' => $this->t('The language code of the URL alias.'),
- );
+ ];
}
/**
diff --git a/core/modules/path/src/Tests/PathAdminTest.php b/core/modules/path/src/Tests/PathAdminTest.php
index 906ce643341..67f41bd2edb 100644
--- a/core/modules/path/src/Tests/PathAdminTest.php
+++ b/core/modules/path/src/Tests/PathAdminTest.php
@@ -14,13 +14,13 @@ class PathAdminTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path');
+ public static $modules = ['path'];
protected function setUp() {
parent::setUp();
// Create test user and log in.
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content', 'administer url aliases', 'create url aliases']);
$this->drupalLogin($web_user);
}
@@ -35,63 +35,63 @@ class PathAdminTest extends PathTestBase {
// Create aliases.
$alias1 = '/' . $this->randomMachineName(8);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node1->id(),
'alias' => $alias1,
- );
+ ];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$alias2 = '/' . $this->randomMachineName(8);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node2->id(),
'alias' => $alias2,
- );
+ ];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$alias3 = '/' . $this->randomMachineName(4) . '/' . $this->randomMachineName(4);
- $edit = array(
+ $edit = [
'source' => '/node/' . $node3->id(),
'alias' => $alias3,
- );
+ ];
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
// Filter by the first alias.
- $edit = array(
+ $edit = [
'filter' => $alias1,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertLinkByHref($alias1);
$this->assertNoLinkByHref($alias2);
$this->assertNoLinkByHref($alias3);
// Filter by the second alias.
- $edit = array(
+ $edit = [
'filter' => $alias2,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertNoLinkByHref($alias1);
$this->assertLinkByHref($alias2);
$this->assertNoLinkByHref($alias3);
// Filter by the third alias which has a slash.
- $edit = array(
+ $edit = [
'filter' => $alias3,
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertNoLinkByHref($alias1);
$this->assertNoLinkByHref($alias2);
$this->assertLinkByHref($alias3);
// Filter by a random string with a different length.
- $edit = array(
+ $edit = [
'filter' => $this->randomMachineName(10),
- );
+ ];
$this->drupalPostForm(NULL, $edit, t('Filter'));
$this->assertNoLinkByHref($alias1);
$this->assertNoLinkByHref($alias2);
// Reset the filter.
- $edit = array();
+ $edit = [];
$this->drupalPostForm(NULL, $edit, t('Reset'));
$this->assertLinkByHref($alias1);
$this->assertLinkByHref($alias2);
diff --git a/core/modules/path/src/Tests/PathNodeFormTest.php b/core/modules/path/src/Tests/PathNodeFormTest.php
index 79b43a77307..016ae04f287 100644
--- a/core/modules/path/src/Tests/PathNodeFormTest.php
+++ b/core/modules/path/src/Tests/PathNodeFormTest.php
@@ -14,13 +14,13 @@ class PathNodeFormTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
protected function setUp() {
parent::setUp();
// Create test user and log in.
- $web_user = $this->drupalCreateUser(array('create page content', 'create url aliases'));
+ $web_user = $this->drupalCreateUser(['create page content', 'create url aliases']);
$this->drupalLogin($web_user);
}
diff --git a/core/modules/path/src/Tests/PathTaxonomyTermTest.php b/core/modules/path/src/Tests/PathTaxonomyTermTest.php
index f62fb6c4c7c..b6a853e97a6 100644
--- a/core/modules/path/src/Tests/PathTaxonomyTermTest.php
+++ b/core/modules/path/src/Tests/PathTaxonomyTermTest.php
@@ -16,7 +16,7 @@ class PathTaxonomyTermTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('taxonomy');
+ public static $modules = ['taxonomy'];
protected function setUp() {
parent::setUp();
@@ -29,7 +29,7 @@ class PathTaxonomyTermTest extends PathTestBase {
$vocabulary->save();
// Create and log in user.
- $web_user = $this->drupalCreateUser(array('administer url aliases', 'administer taxonomy', 'access administration pages'));
+ $web_user = $this->drupalCreateUser(['administer url aliases', 'administer taxonomy', 'access administration pages']);
$this->drupalLogin($web_user);
}
@@ -40,13 +40,13 @@ class PathTaxonomyTermTest extends PathTestBase {
// Create a term in the default 'Tags' vocabulary with URL alias.
$vocabulary = Vocabulary::load('tags');
$description = $this->randomMachineName();
- $edit = array(
+ $edit = [
'name[0][value]' => $this->randomMachineName(),
'description[0][value]' => $description,
'path[0][alias]' => '/' . $this->randomMachineName(),
- );
+ ];
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add', $edit, t('Save'));
- $tid = db_query("SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1", array(':name' => $edit['name[0][value]']))->fetchField();
+ $tid = db_query("SELECT tid FROM {taxonomy_term_field_data} WHERE name = :name AND default_langcode = 1", [':name' => $edit['name[0][value]']])->fetchField();
// Confirm that the alias works.
$this->drupalGet($edit['path[0][alias]']);
@@ -59,7 +59,7 @@ class PathTaxonomyTermTest extends PathTestBase {
$this->assertTrue(!empty($elements), 'Term page contains shortlink URL.');
// Change the term's URL alias.
- $edit2 = array();
+ $edit2 = [];
$edit2['path[0][alias]'] = '/' . $this->randomMachineName();
$this->drupalPostForm('taxonomy/term/' . $tid . '/edit', $edit2, t('Save'));
@@ -73,7 +73,7 @@ class PathTaxonomyTermTest extends PathTestBase {
$this->assertResponse(404, 'Old URL alias returns 404.');
// Remove the term's URL alias.
- $edit3 = array();
+ $edit3 = [];
$edit3['path[0][alias]'] = '';
$this->drupalPostForm('taxonomy/term/' . $tid . '/edit', $edit3, t('Save'));
diff --git a/core/modules/path/src/Tests/PathTestBase.php b/core/modules/path/src/Tests/PathTestBase.php
index 53496768a8d..33cf5aba9dc 100644
--- a/core/modules/path/src/Tests/PathTestBase.php
+++ b/core/modules/path/src/Tests/PathTestBase.php
@@ -17,15 +17,15 @@ abstract class PathTestBase extends WebTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/core/modules/path/tests/src/Functional/PathAliasTest.php b/core/modules/path/tests/src/Functional/PathAliasTest.php
index 5127853ea44..9684aa95ffc 100644
--- a/core/modules/path/tests/src/Functional/PathAliasTest.php
+++ b/core/modules/path/tests/src/Functional/PathAliasTest.php
@@ -19,13 +19,13 @@ class PathAliasTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path');
+ public static $modules = ['path'];
protected function setUp() {
parent::setUp();
// Create test user and log in.
- $web_user = $this->drupalCreateUser(array('create page content', 'edit own page content', 'administer url aliases', 'create url aliases'));
+ $web_user = $this->drupalCreateUser(['create page content', 'edit own page content', 'administer url aliases', 'create url aliases']);
$this->drupalLogin($web_user);
}
@@ -37,7 +37,7 @@ class PathAliasTest extends PathTestBase {
$node1 = $this->drupalCreateNode();
// Create alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node1->id();
$edit['alias'] = '/' . $this->randomMachineName(8);
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
@@ -51,7 +51,7 @@ class PathAliasTest extends PathTestBase {
// created.
\Drupal::cache('data')->deleteAll();
// Make sure the path is not converted to the alias.
- $this->drupalGet(trim($edit['source'], '/'), array('alias' => TRUE));
+ $this->drupalGet(trim($edit['source'], '/'), ['alias' => TRUE]);
$this->assertTrue(\Drupal::cache('data')->get('preload-paths:' . $edit['source']), 'Cache entry was created.');
// Visit the alias for the node and confirm a cache entry is created.
@@ -70,7 +70,7 @@ class PathAliasTest extends PathTestBase {
$node1 = $this->drupalCreateNode();
// Create alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node1->id();
$edit['alias'] = '/' . $this->getRandomGenerator()->word(8);
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
@@ -129,7 +129,7 @@ class PathAliasTest extends PathTestBase {
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
// Confirm no duplicate was created.
- $this->assertRaw(t('The alias %alias is already in use in this language.', array('%alias' => $edit['alias'])), 'Attempt to move alias was rejected.');
+ $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias']]), 'Attempt to move alias was rejected.');
$edit_upper = $edit;
$edit_upper['alias'] = Unicode::strtoupper($edit['alias']);
@@ -142,8 +142,8 @@ class PathAliasTest extends PathTestBase {
// Delete alias.
$this->drupalGet('admin/config/search/path/edit/' . $pid);
$this->clickLink(t('Delete'));
- $this->assertRaw(t('Are you sure you want to delete path alias %name?', array('%name' => $edit['alias'])));
- $this->drupalPostForm(NULL, array(), t('Confirm'));
+ $this->assertRaw(t('Are you sure you want to delete path alias %name?', ['%name' => $edit['alias']]));
+ $this->drupalPostForm(NULL, [], t('Confirm'));
// Confirm that the alias no longer works.
$this->drupalGet($edit['alias']);
@@ -151,7 +151,7 @@ class PathAliasTest extends PathTestBase {
$this->assertResponse(404);
// Create a really long alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node1->id();
$alias = '/' . $this->randomMachineName(128);
$edit['alias'] = $alias;
@@ -166,7 +166,7 @@ class PathAliasTest extends PathTestBase {
$node3 = $this->drupalCreateNode();
// Create absolute path alias.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node3->id();
$node3_alias = '/' . $this->randomMachineName(8);
$edit['alias'] = $node3_alias;
@@ -176,7 +176,7 @@ class PathAliasTest extends PathTestBase {
$node4 = $this->drupalCreateNode();
// Create alias with trailing slash.
- $edit = array();
+ $edit = [];
$edit['source'] = '/node/' . $node4->id();
$node4_alias = '/' . $this->randomMachineName(8);
$edit['alias'] = $node4_alias . '/';
@@ -205,12 +205,12 @@ class PathAliasTest extends PathTestBase {
$edit['alias'] = $node4_alias;
$edit['source'] = '/node/' . $node3->id();
$this->drupalPostForm('admin/config/search/path/edit/' . $pid, $edit, t('Save'));
- $this->assertRaw(t('The alias %alias is already in use in this language.', array('%alias' => $edit['alias'])));
+ $this->assertRaw(t('The alias %alias is already in use in this language.', ['%alias' => $edit['alias']]));
// Create an alias without a starting slash.
$node5 = $this->drupalCreateNode();
- $edit = array();
+ $edit = [];
$edit['source'] = 'node/' . $node5->id();
$node5_alias = $this->randomMachineName(8);
$edit['alias'] = $node5_alias . '/';
@@ -229,7 +229,7 @@ class PathAliasTest extends PathTestBase {
$node1 = $this->drupalCreateNode();
// Create alias.
- $edit = array();
+ $edit = [];
$edit['path[0][alias]'] = '/' . $this->randomMachineName(8);
$this->drupalPostForm('node/' . $node1->id() . '/edit', $edit, t('Save'));
@@ -284,7 +284,7 @@ class PathAliasTest extends PathTestBase {
$this->assertText(t('The alias is already in use.'), 'Attempt to moved alias was rejected.');
// Delete alias.
- $this->drupalPostForm('node/' . $node1->id() . '/edit', array('path[0][alias]' => ''), t('Save'));
+ $this->drupalPostForm('node/' . $node1->id() . '/edit', ['path[0][alias]' => ''], t('Save'));
// Confirm that the alias no longer works.
$this->drupalGet($edit['path[0][alias]']);
@@ -295,7 +295,7 @@ class PathAliasTest extends PathTestBase {
$node3 = $this->drupalCreateNode();
// Set its path alias to an absolute path.
- $edit = array('path[0][alias]' => '/' . $this->randomMachineName(8));
+ $edit = ['path[0][alias]' => '/' . $this->randomMachineName(8)];
$this->drupalPostForm('node/' . $node3->id() . '/edit', $edit, t('Save'));
// Confirm that the alias was converted to a relative path.
@@ -307,7 +307,7 @@ class PathAliasTest extends PathTestBase {
$node4 = $this->drupalCreateNode();
// Set its path alias to have a trailing slash.
- $edit = array('path[0][alias]' => '/' . $this->randomMachineName(8) . '/');
+ $edit = ['path[0][alias]' => '/' . $this->randomMachineName(8) . '/'];
$this->drupalPostForm('node/' . $node4->id() . '/edit', $edit, t('Save'));
// Confirm that the alias was converted to a relative path.
@@ -319,7 +319,7 @@ class PathAliasTest extends PathTestBase {
$node5 = $this->drupalCreateNode();
// Set a path alias.
- $edit = array('path[0][alias]' => '/' . $this->randomMachineName(8));
+ $edit = ['path[0][alias]' => '/' . $this->randomMachineName(8)];
$this->drupalPostForm('node/' . $node5->id() . '/edit', $edit, t('Save'));
// Delete the node and check that the path alias is also deleted.
@@ -338,7 +338,7 @@ class PathAliasTest extends PathTestBase {
* Integer representing the path ID.
*/
function getPID($alias) {
- return db_query("SELECT pid FROM {url_alias} WHERE alias = :alias", array(':alias' => $alias))->fetchField();
+ return db_query("SELECT pid FROM {url_alias} WHERE alias = :alias", [':alias' => $alias])->fetchField();
}
/**
@@ -347,7 +347,7 @@ class PathAliasTest extends PathTestBase {
function testDuplicateNodeAlias() {
// Create one node with a random alias.
$node_one = $this->drupalCreateNode();
- $edit = array();
+ $edit = [];
$edit['path[0][alias]'] = '/' . $this->randomMachineName();
$this->drupalPostForm('node/' . $node_one->id() . '/edit', $edit, t('Save'));
diff --git a/core/modules/path/tests/src/Functional/PathLanguageTest.php b/core/modules/path/tests/src/Functional/PathLanguageTest.php
index 08fe7a4ad24..cd56557ea79 100644
--- a/core/modules/path/tests/src/Functional/PathLanguageTest.php
+++ b/core/modules/path/tests/src/Functional/PathLanguageTest.php
@@ -14,7 +14,7 @@ class PathLanguageTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path', 'locale', 'locale_test', 'content_translation');
+ public static $modules = ['path', 'locale', 'locale_test', 'content_translation'];
/**
* An user with permissions to administer content types.
@@ -26,7 +26,7 @@ class PathLanguageTest extends PathTestBase {
protected function setUp() {
parent::setUp();
- $permissions = array(
+ $permissions = [
'access administration pages',
'administer content translation',
'administer content types',
@@ -37,29 +37,29 @@ class PathLanguageTest extends PathTestBase {
'create url aliases',
'edit any page content',
'translate any entity',
- );
+ ];
// Create and log in user.
$this->webUser = $this->drupalCreateUser($permissions);
$this->drupalLogin($this->webUser);
// Enable French language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => 1);
+ $edit = ['language_interface[enabled][language-url]' => 1];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Enable translation for page node.
- $edit = array(
+ $edit = [
'entity_types[node]' => 1,
'settings[node][page][translatable]' => 1,
'settings[node][page][fields][path]' => 1,
'settings[node][page][fields][body]' => 1,
'settings[node][page][settings][language][language_alterable]' => 1,
- );
+ ];
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
\Drupal::entityManager()->clearCachedDefinitions();
@@ -73,11 +73,11 @@ class PathLanguageTest extends PathTestBase {
*/
function testAliasTranslation() {
$node_storage = $this->container->get('entity.manager')->getStorage('node');
- $english_node = $this->drupalCreateNode(array('type' => 'page', 'langcode' => 'en'));
+ $english_node = $this->drupalCreateNode(['type' => 'page', 'langcode' => 'en']);
$english_alias = $this->randomMachineName();
// Edit the node to set language and path.
- $edit = array();
+ $edit = [];
$edit['path[0][alias]'] = '/' . $english_alias;
$this->drupalPostForm('node/' . $english_node->id() . '/edit', $edit, t('Save'));
@@ -89,7 +89,7 @@ class PathLanguageTest extends PathTestBase {
$this->drupalGet('node/' . $english_node->id() . '/translations');
$this->clickLink(t('Add'));
- $edit = array();
+ $edit = [];
$edit['title[0][value]'] = $this->randomMachineName();
$edit['body[0][value]'] = $this->randomMachineName();
$french_alias = $this->randomMachineName();
@@ -105,7 +105,7 @@ class PathLanguageTest extends PathTestBase {
$languages = $this->container->get('language_manager')->getLanguages();
// Ensure the node was created.
- $node_storage->resetCache(array($english_node->id()));
+ $node_storage->resetCache([$english_node->id()]);
$english_node = $node_storage->load($english_node->id());
$english_node_french_translation = $english_node->getTranslation('fr');
$this->assertTrue($english_node->hasTranslation('fr'), 'Node found in database.');
@@ -118,22 +118,22 @@ class PathLanguageTest extends PathTestBase {
// many levels, and we need to clear those caches.
$this->container->get('language_manager')->reset();
$languages = $this->container->get('language_manager')->getLanguages();
- $url = $english_node_french_translation->url('canonical', array('language' => $languages['fr']));
+ $url = $english_node_french_translation->url('canonical', ['language' => $languages['fr']]);
$this->assertTrue(strpos($url, $edit['path[0][alias]']), 'URL contains the path alias.');
// Confirm that the alias works even when changing language negotiation
// options. Enable User language detection and selection over URL one.
- $edit = array(
+ $edit = [
'language_interface[enabled][language-user]' => 1,
'language_interface[weight][language-user]' => -9,
'language_interface[enabled][language-url]' => 1,
'language_interface[weight][language-url]' => -8,
- );
+ ];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Change user language preference.
- $edit = array('preferred_langcode' => 'fr');
+ $edit = ['preferred_langcode' => 'fr'];
$this->drupalPostForm("user/" . $this->webUser->id() . "/edit", $edit, t('Save'));
// Check that the English alias works. In this situation French is the
@@ -152,7 +152,7 @@ class PathLanguageTest extends PathTestBase {
$this->assertText($english_node_french_translation->body->value, 'Alias for French translation works.');
// Disable URL language negotiation.
- $edit = array('language_interface[enabled][language-url]' => FALSE);
+ $edit = ['language_interface[enabled][language-url]' => FALSE];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check that the English alias still works.
diff --git a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php
index f17bb600856..9bad3485e28 100644
--- a/core/modules/path/tests/src/Functional/PathLanguageUiTest.php
+++ b/core/modules/path/tests/src/Functional/PathLanguageUiTest.php
@@ -14,23 +14,23 @@ class PathLanguageUiTest extends PathTestBase {
*
* @var array
*/
- public static $modules = array('path', 'locale', 'locale_test');
+ public static $modules = ['path', 'locale', 'locale_test'];
protected function setUp() {
parent::setUp();
// Create and log in user.
- $web_user = $this->drupalCreateUser(array('edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages'));
+ $web_user = $this->drupalCreateUser(['edit any page content', 'create page content', 'administer url aliases', 'create url aliases', 'administer languages', 'access administration pages']);
$this->drupalLogin($web_user);
// Enable French language.
- $edit = array();
+ $edit = [];
$edit['predefined_langcode'] = 'fr';
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable URL language detection and selection.
- $edit = array('language_interface[enabled][language-url]' => 1);
+ $edit = ['language_interface[enabled][language-url]' => 1];
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
}
@@ -39,7 +39,7 @@ class PathLanguageUiTest extends PathTestBase {
*/
function testLanguageNeutralUrl() {
$name = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['source'] = '/admin/config/search/path';
$edit['alias'] = '/' . $name;
$this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
@@ -53,7 +53,7 @@ class PathLanguageUiTest extends PathTestBase {
*/
function testDefaultLanguageUrl() {
$name = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['source'] = '/admin/config/search/path';
$edit['alias'] = '/' . $name;
$edit['langcode'] = 'en';
@@ -68,7 +68,7 @@ class PathLanguageUiTest extends PathTestBase {
*/
function testNonDefaultUrl() {
$name = $this->randomMachineName(8);
- $edit = array();
+ $edit = [];
$edit['source'] = '/admin/config/search/path';
$edit['alias'] = '/' . $name;
$edit['langcode'] = 'fr';
diff --git a/core/modules/path/tests/src/Functional/PathTestBase.php b/core/modules/path/tests/src/Functional/PathTestBase.php
index ef83396fd11..d4b8826d58d 100644
--- a/core/modules/path/tests/src/Functional/PathTestBase.php
+++ b/core/modules/path/tests/src/Functional/PathTestBase.php
@@ -14,15 +14,15 @@ abstract class PathTestBase extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('node', 'path');
+ public static $modules = ['node', 'path'];
protected function setUp() {
parent::setUp();
// Create Basic page and Article node types.
if ($this->profile != 'standard') {
- $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
- $this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
+ $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
+ $this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
}
}
diff --git a/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php b/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
index 8df5392fc4d..0580b830cc2 100644
--- a/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
+++ b/core/modules/path/tests/src/Kernel/Migrate/d6/MigrateUrlAliasTest.php
@@ -61,46 +61,46 @@ class MigrateUrlAliasTest extends MigrateDrupal6TestBase {
public function testUrlAlias() {
$id_map = $this->getMigration('d6_url_alias')->getIdMap();
// Test that the field exists.
- $conditions = array(
+ $conditions = [
'source' => '/node/1',
'alias' => '/alias-one',
'langcode' => 'af',
- );
+ ];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('1', $conditions, $path);
- $this->assertIdentical($id_map->lookupDestinationID(array($path['pid'])), array('1'), "Test IdMap");
+ $this->assertIdentical($id_map->lookupDestinationID([$path['pid']]), ['1'], "Test IdMap");
- $conditions = array(
+ $conditions = [
'source' => '/node/2',
'alias' => '/alias-two',
'langcode' => 'en',
- );
+ ];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('2', $conditions, $path);
// Test that we can re-import using the UrlAlias destination.
Database::getConnection('default', 'migrate')
->update('url_alias')
- ->fields(array('dst' => 'new-url-alias'))
+ ->fields(['dst' => 'new-url-alias'])
->condition('src', 'node/2')
->execute();
\Drupal::database()
->update($id_map->mapTableName())
- ->fields(array('source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE))
+ ->fields(['source_row_status' => MigrateIdMapInterface::STATUS_NEEDS_UPDATE])
->execute();
$migration = $this->getMigration('d6_url_alias');
$this->executeMigration($migration);
- $path = \Drupal::service('path.alias_storage')->load(array('pid' => $path['pid']));
+ $path = \Drupal::service('path.alias_storage')->load(['pid' => $path['pid']]);
$conditions['alias'] = '/new-url-alias';
$this->assertPath('2', $conditions, $path);
- $conditions = array(
+ $conditions = [
'source' => '/node/3',
'alias' => '/alias-three',
'langcode' => 'und',
- );
+ ];
$path = \Drupal::service('path.alias_storage')->load($conditions);
$this->assertPath('3', $conditions, $path);
}
diff --git a/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php b/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
index df64a5c2e8b..602e84f42f6 100644
--- a/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
+++ b/core/modules/path/tests/src/Kernel/PathNoCanonicalLinkTest.php
@@ -18,7 +18,7 @@ class PathNoCanonicalLinkTest extends KernelTestBase {
*
* @var array
*/
- public static $modules = array('path', 'content_translation_test', 'language', 'entity_test', 'user', 'system');
+ public static $modules = ['path', 'content_translation_test', 'language', 'entity_test', 'user', 'system'];
protected function setUp() {
parent::setUp();
diff --git a/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php b/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
index 0bb55ae5e8d..7ef7c2f37cf 100644
--- a/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
+++ b/core/modules/path/tests/src/Unit/Field/PathFieldDefinitionTest.php
@@ -21,7 +21,7 @@ class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
* {@inheritdoc}
*/
protected function getModuleAndPath() {
- return array('path', dirname(dirname(dirname(dirname(__DIR__)))));
+ return ['path', dirname(dirname(dirname(dirname(__DIR__))))];
}
/**
@@ -29,7 +29,7 @@ class PathFieldDefinitionTest extends BaseFieldDefinitionTestBase {
* @covers ::getSchema
*/
public function testGetColumns() {
- $this->assertSame(array(), $this->definition->getColumns());
+ $this->assertSame([], $this->definition->getColumns());
}
}