diff --git a/core/modules/action/action.module b/core/modules/action/action.module index 7461302..5004a84 100644 --- a/core/modules/action/action.module +++ b/core/modules/action/action.module @@ -15,13 +15,13 @@ function action_help($route_name, RouteMatchInterface $route_match) { case 'help.page.action': $output = ''; $output .= '
' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the online documentation for the Actions module.', array(':documentation' => 'https://www.drupal.org/documentation/modules/action')) . '
'; + $output .= '' . t('The Actions module provides tasks that can be executed by the site such as unpublishing content, sending email messages, or blocking a user. Other modules can trigger these actions when specific system events happen; for example, when new content is posted or when a user logs in. Modules can also provide additional actions. For more information, see the online documentation for the Actions module.', [':documentation' => 'https://www.drupal.org/documentation/modules/action']) . '
'; $output .= '' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online documentation for the Aggregator module.', array(':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator')) . '
'; + $output .= '' . t('The Aggregator module is an on-site syndicator and news reader that gathers and displays fresh content from RSS-, RDF-, and Atom-based feeds made available across the web. Thousands of sites (particularly news sites and blogs) publish their latest headlines in feeds, using a number of standardized XML-based formats. For more information, see the online documentation for the Aggregator module.', [':aggregator-module' => 'https://www.drupal.org/documentation/modules/aggregator']) . '
'; $output .= '' . t('Many sites publish their headlines and posts in feeds, using a number of standardized XML-based formats. The aggregator supports RSS, RDF, and Atom.') . '
'; - $output .= '' . t('Current feeds are listed below, and new feeds may be added. For each feed, the latest items block may be enabled at the blocks administration page.', array(':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '
'; + $output .= '' . t('Current feeds are listed below, and new feeds may be added. For each feed, the latest items block may be enabled at the blocks administration page.', [':addfeed' => \Drupal::url('aggregator.feed_add'), ':block' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#']) . '
'; return $output; case 'aggregator.feed_add': @@ -68,66 +68,66 @@ function aggregator_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function aggregator_theme() { - return array( - 'aggregator_feed' => array( + return [ + 'aggregator_feed' => [ 'render element' => 'elements', 'file' => 'aggregator.theme.inc', - ), - 'aggregator_item' => array( + ], + 'aggregator_item' => [ 'render element' => 'elements', 'file' => 'aggregator.theme.inc', - ), - ); + ], + ]; } /** * Implements hook_entity_extra_field_info(). */ function aggregator_entity_extra_field_info() { - $extra = array(); + $extra = []; - $extra['aggregator_feed']['aggregator_feed'] = array( - 'display' => array( - 'items' => array( + $extra['aggregator_feed']['aggregator_feed'] = [ + 'display' => [ + 'items' => [ 'label' => t('Items'), 'description' => t('Items associated with this feed'), 'weight' => 0, - ), + ], // @todo Move to a formatter at https://www.drupal.org/node/2339917. - 'image' => array( + 'image' => [ 'label' => t('Image'), 'description' => t('The feed image'), 'weight' => 2, - ), + ], // @todo Move to a formatter at https://www.drupal.org/node/2149845. - 'description' => array( + 'description' => [ 'label' => t('Description'), 'description' => t('The description of this feed'), 'weight' => 3, - ), - 'more_link' => array( + ], + 'more_link' => [ 'label' => t('More link'), 'description' => t('A more link to the feed detail page'), 'weight' => 5, - ), - 'feed_icon' => array( + ], + 'feed_icon' => [ 'label' => t('Feed icon'), 'description' => t('An icon that links to the feed URL'), 'weight' => 6, - ), - ), - ); + ], + ], + ]; - $extra['aggregator_item']['aggregator_item'] = array( - 'display' => array( + $extra['aggregator_item']['aggregator_item'] = [ + 'display' => [ // @todo Move to a formatter at https://www.drupal.org/node/2149845. - 'description' => array( + 'description' => [ 'label' => t('Description'), 'description' => t('The description of this feed item'), 'weight' => 2, - ), - ), - ); + ], + ], + ]; return $extra; } diff --git a/core/modules/aggregator/src/AggregatorFeedViewsData.php b/core/modules/aggregator/src/AggregatorFeedViewsData.php index 2eb0d34..b47f837 100644 --- a/core/modules/aggregator/src/AggregatorFeedViewsData.php +++ b/core/modules/aggregator/src/AggregatorFeedViewsData.php @@ -15,12 +15,12 @@ class AggregatorFeedViewsData extends EntityViewsData { public function getViewsData() { $data = parent::getViewsData(); - $data['aggregator_feed']['table']['join'] = array( - 'aggregator_item' => array( + $data['aggregator_feed']['table']['join'] = [ + 'aggregator_item' => [ 'left_field' => 'fid', 'field' => 'fid', - ), - ); + ], + ]; $data['aggregator_feed']['fid']['help'] = $this->t('The unique ID of the aggregator feed.'); $data['aggregator_feed']['fid']['argument']['id'] = 'aggregator_fid'; diff --git a/core/modules/aggregator/src/Controller/AggregatorController.php b/core/modules/aggregator/src/Controller/AggregatorController.php index c84fb18..021e4d1 100644 --- a/core/modules/aggregator/src/Controller/AggregatorController.php +++ b/core/modules/aggregator/src/Controller/AggregatorController.php @@ -48,9 +48,9 @@ public static function create(ContainerInterface $container) { */ public function feedAdd() { $feed = $this->entityManager()->getStorage('aggregator_feed') - ->create(array( + ->create([ 'refresh' => 3600, - )); + ]); return $this->entityFormBuilder()->getForm($feed); } @@ -67,15 +67,15 @@ public function feedAdd() { */ protected function buildPageList(array $items, $feed_source = '') { // Assemble output. - $build = array( + $build = [ '#type' => 'container', - '#attributes' => array('class' => array('aggregator-wrapper')), - ); - $build['feed_source'] = is_array($feed_source) ? $feed_source : array('#markup' => $feed_source); + '#attributes' => ['class' => ['aggregator-wrapper']], + ]; + $build['feed_source'] = is_array($feed_source) ? $feed_source : ['#markup' => $feed_source]; if ($items) { $build['items'] = $this->entityManager()->getViewBuilder('aggregator_item') ->viewMultiple($items, 'default'); - $build['pager'] = array('#type' => 'pager'); + $build['pager'] = ['#type' => 'pager']; } return $build; } @@ -94,8 +94,8 @@ protected function buildPageList(array $items, $feed_source = '') { */ public function feedRefresh(FeedInterface $aggregator_feed) { $message = $aggregator_feed->refreshItems() - ? $this->t('There is new syndicated content from %site.', array('%site' => $aggregator_feed->label())) - : $this->t('There is no new syndicated content from %site.', array('%site' => $aggregator_feed->label())); + ? $this->t('There is new syndicated content from %site.', ['%site' => $aggregator_feed->label()]) + : $this->t('There is no new syndicated content from %site.', ['%site' => $aggregator_feed->label()]); drupal_set_message($message); return $this->redirect('aggregator.admin_overview'); } @@ -111,22 +111,22 @@ public function adminOverview() { $feeds = $entity_manager->getStorage('aggregator_feed') ->loadMultiple(); - $header = array($this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations')); - $rows = array(); + $header = [$this->t('Title'), $this->t('Items'), $this->t('Last update'), $this->t('Next update'), $this->t('Operations')]; + $rows = []; /** @var \Drupal\aggregator\FeedInterface[] $feeds */ foreach ($feeds as $feed) { - $row = array(); + $row = []; $row[] = $feed->link(); $row[] = $this->formatPlural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items'); $last_checked = $feed->getLastCheckedTime(); $refresh_rate = $feed->getRefreshRate(); - $row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never')); + $row[] = ($last_checked ? $this->t('@time ago', ['@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked)]) : $this->t('never')); if (!$last_checked && $refresh_rate) { $next_update = $this->t('imminently'); } elseif ($last_checked && $refresh_rate) { - $next_update = $next = $this->t('%time left', array('%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME))); + $next_update = $next = $this->t('%time left', ['%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)]); } else { $next_update = $this->t('never'); @@ -136,33 +136,33 @@ public function adminOverview() { 'title' => $this->t('Edit'), 'url' => Url::fromRoute('entity.aggregator_feed.edit_form', ['aggregator_feed' => $feed->id()]), ]; - $links['delete'] = array( + $links['delete'] = [ 'title' => $this->t('Delete'), 'url' => Url::fromRoute('entity.aggregator_feed.delete_form', ['aggregator_feed' => $feed->id()]), - ); - $links['delete_items'] = array( + ]; + $links['delete_items'] = [ 'title' => $this->t('Delete items'), 'url' => Url::fromRoute('aggregator.feed_items_delete', ['aggregator_feed' => $feed->id()]), - ); - $links['update'] = array( + ]; + $links['update'] = [ 'title' => $this->t('Update items'), 'url' => Url::fromRoute('aggregator.feed_refresh', ['aggregator_feed' => $feed->id()]), - ); - $row[] = array( - 'data' => array( + ]; + $row[] = [ + 'data' => [ '#type' => 'operations', '#links' => $links, - ), - ); + ], + ]; $rows[] = $row; } - $build['feeds'] = array( + $build['feeds'] = [ '#prefix' => ' ' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see the online documentation for the Ban module.', array(':url' => 'https://www.drupal.org/documentation/modules/ban')) . ' ' . t('The Ban module allows administrators to ban visits to their site from individual IP addresses. For more information, see the online documentation for the Ban module.', [':url' => 'https://www.drupal.org/documentation/modules/ban']) . ' ' . t('The HTTP Basic Authentication module supplies an HTTP Basic authentication provider for web service requests. This authentication provider authenticates requests using the HTTP Basic Authentication username and password, as an alternative to using Drupal\'s standard cookie-based authentication system. It is only useful if your site provides web services configured to use this type of authentication (for instance, the RESTful Web Services module). For more information, see the online documentation for the HTTP Basic Authentication module.', array(':hba_do' => 'https://www.drupal.org/documentation/modules/basic_auth', ':rest_help' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', array('name' => 'rest')) : '#')) . ' ' . t('The HTTP Basic Authentication module supplies an HTTP Basic authentication provider for web service requests. This authentication provider authenticates requests using the HTTP Basic Authentication username and password, as an alternative to using Drupal\'s standard cookie-based authentication system. It is only useful if your site provides web services configured to use this type of authentication (for instance, the RESTful Web Services module). For more information, see the online documentation for the HTTP Basic Authentication module.', [':hba_do' => 'https://www.drupal.org/documentation/modules/basic_auth', ':rest_help' => (\Drupal::moduleHandler()->moduleExists('rest')) ? \Drupal::url('help.page', ['name' => 'rest']) : '#']) . ' ' . t('The Block module allows you to place blocks in regions of your installed themes, and configure block settings. For more information, see the online documentation for the Block module.', array(':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block/')) . ' ' . t('The Block module allows you to place blocks in regions of your installed themes, and configure block settings. For more information, see the online documentation for the Block module.', [':blocks-documentation' => 'https://www.drupal.org/documentation/modules/block/']) . ' ' . t('Block placement is specific to each theme on your site. Changes will not be saved until you click Save blocks at the bottom of the page.') . ' ' . \Drupal::l(t('Demonstrate block regions (@theme)', array('@theme' => $themes[$demo_theme]->info['name'])), new Url('block.admin_demo', array('theme' => $demo_theme))) . ' ' . \Drupal::l(t('Demonstrate block regions (@theme)', ['@theme' => $themes[$demo_theme]->info['name']]), new Url('block.admin_demo', ['theme' => $demo_theme])) . '', $config->get('items.allowed_html'));
$this->assertIdentical(9676800, $config->get('items.expire'));
diff --git a/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php b/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php
index a72da23..39f57b2 100644
--- a/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php
+++ b/core/modules/aggregator/tests/src/Kernel/Views/IntegrationTest.php
@@ -21,14 +21,14 @@ class IntegrationTest extends ViewsKernelTestBase {
*
* @var array
*/
- public static $modules = array('aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user');
+ public static $modules = ['aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user'];
/**
* Views used by this test.
*
* @var array
*/
- public static $testViews = array('test_aggregator_items');
+ public static $testViews = ['test_aggregator_items'];
/**
* The entity storage for aggregator items.
@@ -53,7 +53,7 @@ protected function setUp($import_test_views = TRUE) {
$this->installEntitySchema('aggregator_item');
$this->installEntitySchema('aggregator_feed');
- ViewTestData::createTestViews(get_class($this), array('aggregator_test_views'));
+ ViewTestData::createTestViews(get_class($this), ['aggregator_test_views']);
$this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item');
$this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed');
@@ -66,19 +66,19 @@ public function testAggregatorItemView() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
- $feed = $this->feedStorage->create(array(
+ $feed = $this->feedStorage->create([
'title' => $this->randomMachineName(),
'url' => 'https://www.drupal.org/',
'refresh' => 900,
'checked' => 123543535,
'description' => $this->randomMachineName(),
- ));
+ ]);
$feed->save();
- $items = array();
- $expected = array();
+ $items = [];
+ $expected = [];
for ($i = 0; $i < 10; $i++) {
- $values = array();
+ $values = [];
$values['fid'] = $feed->id();
$values['timestamp'] = mt_rand(REQUEST_TIME - 10, REQUEST_TIME + 10);
$values['title'] = $this->randomMachineName();
@@ -99,13 +99,13 @@ public function testAggregatorItemView() {
$view = Views::getView('test_aggregator_items');
$this->executeView($view);
- $column_map = array(
+ $column_map = [
'iid' => 'iid',
'title' => 'title',
'aggregator_item_timestamp' => 'timestamp',
'description' => 'description',
'aggregator_item_author' => 'author',
- );
+ ];
$this->assertIdenticalResultset($view, $expected, $column_map);
// Ensure that the rendering of the linked title works as expected.
diff --git a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
index c9f6906..7a78ad9 100644
--- a/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
+++ b/core/modules/aggregator/tests/src/Unit/Menu/AggregatorLocalTasksTest.php
@@ -15,7 +15,7 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
* {@inheritdoc}
*/
protected function setUp() {
- $this->directoryList = array('aggregator' => 'core/modules/aggregator');
+ $this->directoryList = ['aggregator' => 'core/modules/aggregator'];
parent::setUp();
}
@@ -25,19 +25,19 @@ protected function setUp() {
* @dataProvider getAggregatorAdminRoutes
*/
public function testAggregatorAdminLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('aggregator.admin_overview', 'aggregator.admin_settings'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['aggregator.admin_overview', 'aggregator.admin_settings'],
+ ]);
}
/**
* Provides a list of routes to test.
*/
public function getAggregatorAdminRoutes() {
- return array(
- array('aggregator.admin_overview'),
- array('aggregator.admin_settings'),
- );
+ return [
+ ['aggregator.admin_overview'],
+ ['aggregator.admin_settings'],
+ ];
}
/**
@@ -46,9 +46,9 @@ public function getAggregatorAdminRoutes() {
* @dataProvider getAggregatorSourceRoutes
*/
public function testAggregatorSourceLocalTasks($route) {
- $this->assertLocalTasks($route, array(
- 0 => array('entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'),
- ));
+ $this->assertLocalTasks($route, [
+ 0 => ['entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'],
+ ]);
;
}
@@ -56,10 +56,10 @@ public function testAggregatorSourceLocalTasks($route) {
* Provides a list of source routes to test.
*/
public function getAggregatorSourceRoutes() {
- return array(
- array('entity.aggregator_feed.canonical'),
- array('entity.aggregator_feed.edit_form'),
- );
+ return [
+ ['entity.aggregator_feed.canonical'],
+ ['entity.aggregator_feed.edit_form'],
+ ];
}
}
diff --git a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
index 87a5d93..9267237 100644
--- a/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
+++ b/core/modules/aggregator/tests/src/Unit/Plugin/AggregatorPluginSettingsBaseTest.php
@@ -39,20 +39,20 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
*/
protected function setUp() {
$this->configFactory = $this->getConfigFactoryStub(
- array(
- 'aggregator.settings' => array(
- 'processors' => array('aggregator_test'),
- ),
- 'aggregator_test.settings' => array(),
- )
+ [
+ 'aggregator.settings' => [
+ 'processors' => ['aggregator_test'],
+ ],
+ 'aggregator_test.settings' => [],
+ ]
);
- foreach (array('fetcher', 'parser', 'processor') as $type) {
+ foreach (['fetcher', 'parser', 'processor'] as $type) {
$this->managers[$type] = $this->getMockBuilder('Drupal\aggregator\Plugin\AggregatorPluginManager')
->disableOriginalConstructor()
->getMock();
$this->managers[$type]->expects($this->once())
->method('getDefinitions')
- ->will($this->returnValue(array('aggregator_test' => array('title' => '', 'description' => ''))));
+ ->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']]));
}
$this->settingsForm = new SettingsForm(
@@ -79,8 +79,8 @@ public function testSettingsForm() {
$test_processor = $this->getMock(
'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor',
- array('buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'),
- array(array(), 'aggregator_test', array('description' => ''), $this->configFactory)
+ ['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'],
+ [[], 'aggregator_test', ['description' => ''], $this->configFactory]
);
$test_processor->expects($this->at(0))
->method('buildConfigurationForm')
@@ -98,7 +98,7 @@ public function testSettingsForm() {
->with($this->equalTo('aggregator_test'))
->will($this->returnValue($test_processor));
- $form = $this->settingsForm->buildForm(array(), $form_state);
+ $form = $this->settingsForm->buildForm([], $form_state);
$this->settingsForm->validateForm($form, $form_state);
$this->settingsForm->submitForm($form, $form_state);
}
diff --git a/core/modules/ban/ban.install b/core/modules/ban/ban.install
index b2ea1fe..f3c003a 100644
--- a/core/modules/ban/ban.install
+++ b/core/modules/ban/ban.install
@@ -9,27 +9,27 @@
* Implements hook_schema().
*/
function ban_schema() {
- $schema['ban_ip'] = array(
+ $schema['ban_ip'] = [
'description' => 'Stores banned IP addresses.',
- 'fields' => array(
- 'iid' => array(
+ 'fields' => [
+ 'iid' => [
'description' => 'Primary Key: unique ID for IP addresses.',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
- ),
- 'ip' => array(
+ ],
+ 'ip' => [
'description' => 'IP address',
'type' => 'varchar_ascii',
'length' => 40,
'not null' => TRUE,
'default' => '',
- ),
- ),
- 'indexes' => array(
- 'ip' => array('ip'),
- ),
- 'primary key' => array('iid'),
- );
+ ],
+ ],
+ 'indexes' => [
+ 'ip' => ['ip'],
+ ],
+ 'primary key' => ['iid'],
+ ];
return $schema;
}
diff --git a/core/modules/ban/ban.module b/core/modules/ban/ban.module
index a1ee238..b8b72c5 100644
--- a/core/modules/ban/ban.module
+++ b/core/modules/ban/ban.module
@@ -15,11 +15,11 @@ function ban_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.ban':
$output = '';
$output .= '
' . t('About') . '
';
- $output .= '' . t('Uses') . '
';
$output .= '';
$output .= '
';
return $output;
diff --git a/core/modules/ban/src/BanIpManager.php b/core/modules/ban/src/BanIpManager.php
index a92731c..d354f7a 100644
--- a/core/modules/ban/src/BanIpManager.php
+++ b/core/modules/ban/src/BanIpManager.php
@@ -30,7 +30,7 @@ public function __construct(Connection $connection) {
* {@inheritdoc}
*/
public function isBanned($ip) {
- return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", array(':ip' => $ip))->fetchField();
+ return (bool) $this->connection->query("SELECT * FROM {ban_ip} WHERE ip = :ip", [':ip' => $ip])->fetchField();
}
/**
@@ -45,8 +45,8 @@ public function findAll() {
*/
public function banIp($ip) {
$this->connection->merge('ban_ip')
- ->key(array('ip' => $ip))
- ->fields(array('ip' => $ip))
+ ->key(['ip' => $ip])
+ ->fields(['ip' => $ip])
->execute();
}
@@ -63,7 +63,7 @@ public function unbanIp($id) {
* {@inheritdoc}
*/
public function findById($ban_id) {
- return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", array(':iid' => $ban_id))->fetchField();
+ return $this->connection->query("SELECT ip FROM {ban_ip} WHERE iid = :iid", [':iid' => $ban_id])->fetchField();
}
}
diff --git a/core/modules/ban/src/Form/BanAdmin.php b/core/modules/ban/src/Form/BanAdmin.php
index a0c769f..731d065 100644
--- a/core/modules/ban/src/Form/BanAdmin.php
+++ b/core/modules/ban/src/Form/BanAdmin.php
@@ -52,47 +52,47 @@ public function getFormId() {
* address form field.
*/
public function buildForm(array $form, FormStateInterface $form_state, $default_ip = '') {
- $rows = array();
- $header = array($this->t('banned IP addresses'), $this->t('Operations'));
+ $rows = [];
+ $header = [$this->t('banned IP addresses'), $this->t('Operations')];
$result = $this->ipManager->findAll();
foreach ($result as $ip) {
- $row = array();
+ $row = [];
$row[] = $ip->ip;
- $links = array();
- $links['delete'] = array(
+ $links = [];
+ $links['delete'] = [
'title' => $this->t('Delete'),
'url' => Url::fromRoute('ban.delete', ['ban_id' => $ip->iid]),
- );
- $row[] = array(
- 'data' => array(
+ ];
+ $row[] = [
+ 'data' => [
'#type' => 'operations',
'#links' => $links,
- ),
- );
+ ],
+ ];
$rows[] = $row;
}
- $form['ip'] = array(
+ $form['ip'] = [
'#title' => $this->t('IP address'),
'#type' => 'textfield',
'#size' => 48,
'#maxlength' => 40,
'#default_value' => $default_ip,
'#description' => $this->t('Enter a valid IP address.'),
- );
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
+ ];
+ $form['actions'] = ['#type' => 'actions'];
+ $form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this->t('Add'),
- );
+ ];
- $form['ban_ip_banning_table'] = array(
+ $form['ban_ip_banning_table'] = [
'#type' => 'table',
'#header' => $header,
'#rows' => $rows,
'#empty' => $this->t('No blocked IP addresses available.'),
'#weight' => 120,
- );
+ ];
return $form;
}
@@ -118,7 +118,7 @@ public function validateForm(array &$form, FormStateInterface $form_state) {
public function submitForm(array &$form, FormStateInterface $form_state) {
$ip = trim($form_state->getValue('ip'));
$this->ipManager->banIp($ip);
- drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip)));
+ drupal_set_message($this->t('The IP address %ip has been banned.', ['%ip' => $ip]));
$form_state->setRedirect('ban.admin_page');
}
diff --git a/core/modules/ban/src/Form/BanDelete.php b/core/modules/ban/src/Form/BanDelete.php
index a8a4962..3d14ca3 100644
--- a/core/modules/ban/src/Form/BanDelete.php
+++ b/core/modules/ban/src/Form/BanDelete.php
@@ -58,7 +58,7 @@ public function getFormId() {
* {@inheritdoc}
*/
public function getQuestion() {
- return $this->t('Are you sure you want to unblock %ip?', array('%ip' => $this->banIp));
+ return $this->t('Are you sure you want to unblock %ip?', ['%ip' => $this->banIp]);
}
/**
@@ -93,8 +93,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $ban_id =
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->ipManager->unbanIp($this->banIp);
- $this->logger('user')->notice('Deleted %ip', array('%ip' => $this->banIp));
- drupal_set_message($this->t('The IP address %ip was deleted.', array('%ip' => $this->banIp)));
+ $this->logger('user')->notice('Deleted %ip', ['%ip' => $this->banIp]);
+ drupal_set_message($this->t('The IP address %ip was deleted.', ['%ip' => $this->banIp]));
$form_state->setRedirectUrl($this->getCancelUrl());
}
diff --git a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php
index 94135fd..7c570bb 100644
--- a/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php
+++ b/core/modules/ban/src/Plugin/migrate/destination/BlockedIp.php
@@ -76,7 +76,7 @@ public function fields(MigrationInterface $migration = NULL) {
/**
* {@inheritdoc}
*/
- public function import(Row $row, array $old_destination_id_values = array()) {
+ public function import(Row $row, array $old_destination_id_values = []) {
$this->banManager->banIp($row->getDestinationProperty('ip'));
}
diff --git a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
index 9738915..0a155fb 100644
--- a/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
+++ b/core/modules/ban/tests/src/Functional/IpAddressBlockingTest.php
@@ -18,55 +18,55 @@ class IpAddressBlockingTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('ban');
+ public static $modules = ['ban'];
/**
* Tests various user input to confirm correct validation and saving of data.
*/
function testIPAddressValidation() {
// Create user.
- $admin_user = $this->drupalCreateUser(array('ban IP addresses'));
+ $admin_user = $this->drupalCreateUser(['ban IP addresses']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/config/people/ban');
// Ban a valid IP address.
- $edit = array();
+ $edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
- $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", array(':ip' => $edit['ip']))->fetchField();
+ $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $edit['ip']])->fetchField();
$this->assertTrue($ip, 'IP address found in database.');
- $this->assertRaw(t('The IP address %ip has been banned.', array('%ip' => $edit['ip'])), 'IP address was banned.');
+ $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $edit['ip']]), 'IP address was banned.');
// Try to block an IP address that's already blocked.
- $edit = array();
+ $edit = [];
$edit['ip'] = '1.2.3.3';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('This IP address is already banned.'));
// Try to block a reserved IP address.
- $edit = array();
+ $edit = [];
$edit['ip'] = '255.255.255.255';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.'));
// Try to block a reserved IP address.
- $edit = array();
+ $edit = [];
$edit['ip'] = 'test.example.com';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.'));
// Submit an empty form.
- $edit = array();
+ $edit = [];
$edit['ip'] = '';
$this->drupalPostForm('admin/config/people/ban', $edit, t('Add'));
$this->assertText(t('Enter a valid IP address.'));
// Pass an IP address as a URL parameter and submit it.
$submit_ip = '1.2.3.4';
- $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, array(), t('Add'));
- $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", array(':ip' => $submit_ip))->fetchField();
+ $this->drupalPostForm('admin/config/people/ban/' . $submit_ip, [], t('Add'));
+ $ip = db_query("SELECT iid from {ban_ip} WHERE ip = :ip", [':ip' => $submit_ip])->fetchField();
$this->assertTrue($ip, 'IP address found in database');
- $this->assertRaw(t('The IP address %ip has been banned.', array('%ip' => $submit_ip)), 'IP address was banned.');
+ $this->assertRaw(t('The IP address %ip has been banned.', ['%ip' => $submit_ip]), 'IP address was banned.');
// Submit your own IP address. This fails, although it works when testing
// manually.
@@ -85,7 +85,7 @@ function testIPAddressValidation() {
$banIp->banIp($ip);
$banIp->banIp($ip);
$query = db_select('ban_ip', 'bip');
- $query->fields('bip', array('iid'));
+ $query->fields('bip', ['iid']);
$query->condition('bip.ip', $ip);
$ip_count = $query->execute()->fetchAll();
$this->assertEqual(1, count($ip_count));
@@ -93,7 +93,7 @@ function testIPAddressValidation() {
$banIp->banIp($ip);
$banIp->banIp($ip);
$query = db_select('ban_ip', 'bip');
- $query->fields('bip', array('iid'));
+ $query->fields('bip', ['iid']);
$query->condition('bip.ip', $ip);
$ip_count = $query->execute()->fetchAll();
$this->assertEqual(1, count($ip_count));
diff --git a/core/modules/basic_auth/basic_auth.module b/core/modules/basic_auth/basic_auth.module
index ea64c5b..7d1d01f 100644
--- a/core/modules/basic_auth/basic_auth.module
+++ b/core/modules/basic_auth/basic_auth.module
@@ -15,7 +15,7 @@ function basic_auth_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.basic_auth':
$output = '';
$output .= '' . t('About') . '
';
- $output .= '' . t('About') . '
';
- $output .= '' . t('Uses') . '
';
$output .= '';
$output .= '
';
return $output;
}
@@ -43,7 +43,7 @@ function block_help($route_name, RouteMatchInterface $route_match) {
$demo_theme = $route_match->getParameter('theme') ?: \Drupal::config('system.theme')->get('default');
$themes = \Drupal::service('theme_handler')->listInfo();
$output = '';
foreach ($blocks as $disabled_block_id => $disabled_block) {
- $message .= '
' . t('The Custom Block module allows you to create and manage custom block types and content-containing blocks from the Custom block library page. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', array(':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', array('name' => 'field')), ':blocks' => \Drupal::url('help.page', array('name' => 'block')), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content')) . '
'; + $output .= '' . t('The Custom Block module allows you to create and manage custom block types and content-containing blocks from the Custom block library page. Custom block types have fields; see the Field module help for more information. Once created, custom blocks can be placed in regions just like blocks provided by other modules; see the Block module help page for details. For more information, see the online documentation for the Custom Block module.', [':block-library' => \Drupal::url('entity.block_content.collection'), ':block-content' => \Drupal::url('entity.block_content.collection'), ':field-help' => \Drupal::url('help.page', ['name' => 'field']), ':blocks' => \Drupal::url('help.page', ['name' => 'block']), ':online-help' => 'https://www.drupal.org/documentation/modules/block_content']) . '
'; $output .= '' . t('Blocks in the block library belong to Custom block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', array(':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display'))) . '
'; + $output = '' . t('Blocks in the block library belong to Custom block types, each with its own fields and display settings. After creating a block, place it in a region from the Block layout page.', [':types' => \Drupal::url('entity.block_content_type.collection'), ':blocks' => \Drupal::url('block.admin_display')]) . '
'; return $output; case 'entity.block_content_type.collection': - $output = '' . t('Each block type has its own fields and display settings. Create blocks of each type on the Blocks page in the custom block library.', array(':block-library' => \Drupal::url('entity.block_content.collection'))) . '
'; + $output = '' . t('Each block type has its own fields and display settings. Create blocks of each type on the Blocks page in the custom block library.', [':block-library' => \Drupal::url('entity.block_content.collection')]) . '
'; return $output; } @@ -43,12 +43,12 @@ function block_content_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function block_content_theme($existing, $type, $theme, $path) { - return array( - 'block_content_add_list' => array( - 'variables' => array('content' => NULL), + return [ + 'block_content_add_list' => [ + 'variables' => ['content' => NULL], 'file' => 'block_content.pages.inc', - ), - ); + ], + ]; } /** @@ -83,23 +83,23 @@ function block_content_add_body_field($block_type_id, $label = 'Body') { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_type_id, 'label' => $label, - 'settings' => array('display_summary' => FALSE), + 'settings' => ['display_summary' => FALSE], ]); $field->save(); // Assign widget settings for the 'default' form mode. entity_get_form_display('block_content', $block_type_id, 'default') - ->setComponent('body', array( + ->setComponent('body', [ 'type' => 'text_textarea_with_summary', - )) + ]) ->save(); // Assign display settings for 'default' view mode. entity_get_display('block_content', $block_type_id, 'default') - ->setComponent('body', array( + ->setComponent('body', [ 'label' => 'hidden', 'type' => 'text_default', - )) + ]) ->save(); } diff --git a/core/modules/block_content/block_content.pages.inc b/core/modules/block_content/block_content.pages.inc index 8629690..e50e717 100644 --- a/core/modules/block_content/block_content.pages.inc +++ b/core/modules/block_content/block_content.pages.inc @@ -19,18 +19,18 @@ * @see block_content_add_page() */ function template_preprocess_block_content_add_list(&$variables) { - $variables['types'] = array(); + $variables['types'] = []; $query = \Drupal::request()->query->all(); foreach ($variables['content'] as $type) { - $variables['types'][$type->id()] = array( - 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', array('block_content_type' => $type->id()), array('query' => $query))), - 'description' => array( + $variables['types'][$type->id()] = [ + 'link' => \Drupal::l($type->label(), new Url('block_content.add_form', ['block_content_type' => $type->id()], ['query' => $query])), + 'description' => [ '#markup' => $type->getDescription(), - ), + ], 'title' => $type->label(), - 'localized_options' => array( + 'localized_options' => [ 'query' => $query, - ), - ); + ], + ]; } } diff --git a/core/modules/block_content/src/BlockContentForm.php b/core/modules/block_content/src/BlockContentForm.php index b3f50f7..eefd4e9 100644 --- a/core/modules/block_content/src/BlockContentForm.php +++ b/core/modules/block_content/src/BlockContentForm.php @@ -27,7 +27,7 @@ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); if ($this->operation == 'edit') { - $form['#title'] = $this->t('Edit custom block %label', array('%label' => $block->label())); + $form['#title'] = $this->t('Edit custom block %label', ['%label' => $block->label()]); } // Override the default CSS class name, since the user-defined custom block // type name in 'TYPE-block-form' potentially clashes with third-party class @@ -45,10 +45,10 @@ public function save(array $form, FormStateInterface $form_state) { $insert = $block->isNew(); $block->save(); - $context = array('@type' => $block->bundle(), '%info' => $block->label()); + $context = ['@type' => $block->bundle(), '%info' => $block->label()]; $logger = $this->logger('block_content'); $block_type = $this->getBundleEntity(); - $t_args = array('@type' => $block_type->label(), '%info' => $block->label()); + $t_args = ['@type' => $block_type->label(), '%info' => $block->label()]; if ($insert) { $logger->notice('@type: added %info.', $context); @@ -68,10 +68,10 @@ public function save(array $form, FormStateInterface $form_state) { } $form_state->setRedirect( 'block.admin_add', - array( + [ 'plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme, - ) + ] ); } else { diff --git a/core/modules/block_content/src/BlockContentTranslationHandler.php b/core/modules/block_content/src/BlockContentTranslationHandler.php index b446cde..612613b 100644 --- a/core/modules/block_content/src/BlockContentTranslationHandler.php +++ b/core/modules/block_content/src/BlockContentTranslationHandler.php @@ -16,7 +16,7 @@ class BlockContentTranslationHandler extends ContentTranslationHandler { */ protected function entityFormTitle(EntityInterface $entity) { $block_type = BlockContentType::load($entity->bundle()); - return t('Edit @type @title', array('@type' => $block_type->label(), '@title' => $entity->label())); + return t('Edit @type @title', ['@type' => $block_type->label(), '@title' => $entity->label()]); } } diff --git a/core/modules/block_content/src/BlockContentTypeForm.php b/core/modules/block_content/src/BlockContentTypeForm.php index d864e8d..4e140b1 100644 --- a/core/modules/block_content/src/BlockContentTypeForm.php +++ b/core/modules/block_content/src/BlockContentTypeForm.php @@ -25,65 +25,65 @@ public function form(array $form, FormStateInterface $form_state) { $form['#title'] = $this->t('Add custom block type'); } else { - $form['#title'] = $this->t('Edit %label custom block type', array('%label' => $block_type->label())); + $form['#title'] = $this->t('Edit %label custom block type', ['%label' => $block_type->label()]); } - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => t('Label'), '#maxlength' => 255, '#default_value' => $block_type->label(), '#description' => t("Provide a label for this block type to help identify it in the administration pages."), '#required' => TRUE, - ); - $form['id'] = array( + ]; + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $block_type->id(), - '#machine_name' => array( + '#machine_name' => [ 'exists' => '\Drupal\block_content\Entity\BlockContentType::load', - ), + ], '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, - ); + ]; - $form['description'] = array( + $form['description'] = [ '#type' => 'textarea', '#default_value' => $block_type->getDescription(), '#description' => t('Enter a description for this block type.'), '#title' => t('Description'), - ); + ]; - $form['revision'] = array( + $form['revision'] = [ '#type' => 'checkbox', '#title' => t('Create new revision'), '#default_value' => $block_type->shouldCreateNewRevision(), '#description' => t('Create a new revision by default for this block type.'), - ); + ]; if ($this->moduleHandler->moduleExists('language')) { - $form['language'] = array( + $form['language'] = [ '#type' => 'details', '#title' => t('Language settings'), '#group' => 'additional_settings', - ); + ]; $language_configuration = ContentLanguageSettings::loadByEntityTypeBundle('block_content', $block_type->id()); - $form['language']['language_configuration'] = array( + $form['language']['language_configuration'] = [ '#type' => 'language_configuration', - '#entity_information' => array( + '#entity_information' => [ 'entity_type' => 'block_content', 'bundle' => $block_type->id(), - ), + ], '#default_value' => $language_configuration, - ); + ]; $form['#submit'][] = 'language_configuration_element_submit'; } - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => t('Save'), - ); + ]; return $this->protectBundleIdElement($form); } @@ -98,13 +98,13 @@ public function save(array $form, FormStateInterface $form_state) { $edit_link = $this->entity->link($this->t('Edit')); $logger = $this->logger('block_content'); if ($status == SAVED_UPDATED) { - drupal_set_message(t('Custom block type %label has been updated.', array('%label' => $block_type->label()))); - $logger->notice('Custom block type %label has been updated.', array('%label' => $block_type->label(), 'link' => $edit_link)); + drupal_set_message(t('Custom block type %label has been updated.', ['%label' => $block_type->label()])); + $logger->notice('Custom block type %label has been updated.', ['%label' => $block_type->label(), 'link' => $edit_link]); } else { block_content_add_body_field($block_type->id()); - drupal_set_message(t('Custom block type %label has been added.', array('%label' => $block_type->label()))); - $logger->notice('Custom block type %label has been added.', array('%label' => $block_type->label(), 'link' => $edit_link)); + drupal_set_message(t('Custom block type %label has been added.', ['%label' => $block_type->label()])); + $logger->notice('Custom block type %label has been added.', ['%label' => $block_type->label(), 'link' => $edit_link]); } $form_state->setRedirectUrl($this->entity->urlInfo('collection')); diff --git a/core/modules/block_content/src/BlockContentViewBuilder.php b/core/modules/block_content/src/BlockContentViewBuilder.php index 322a087..29c668c 100644 --- a/core/modules/block_content/src/BlockContentViewBuilder.php +++ b/core/modules/block_content/src/BlockContentViewBuilder.php @@ -15,13 +15,13 @@ class BlockContentViewBuilder extends EntityViewBuilder { * {@inheritdoc} */ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { - return $this->viewMultiple(array($entity), $view_mode, $langcode)[0]; + return $this->viewMultiple([$entity], $view_mode, $langcode)[0]; } /** * {@inheritdoc} */ - public function viewMultiple(array $entities = array(), $view_mode = 'full', $langcode = NULL) { + public function viewMultiple(array $entities = [], $view_mode = 'full', $langcode = NULL) { $build_list = parent::viewMultiple($entities, $view_mode, $langcode); // Apply the buildMultiple() #pre_render callback immediately, to make // bubbling of attributes and contextual links to the actual block work. @@ -48,10 +48,10 @@ protected function alterBuild(array &$build, EntityInterface $entity, EntityView parent::alterBuild($build, $entity, $display, $view_mode); // Add contextual links for this custom block. if (!$entity->isNew()) { - $build['#contextual_links']['block_content'] = array( - 'route_parameters' => array('block_content' => $entity->id()), - 'metadata' => array('changed' => $entity->getChangedTime()), - ); + $build['#contextual_links']['block_content'] = [ + 'route_parameters' => ['block_content' => $entity->id()], + 'metadata' => ['changed' => $entity->getChangedTime()], + ]; } } diff --git a/core/modules/block_content/src/BlockContentViewsData.php b/core/modules/block_content/src/BlockContentViewsData.php index 1d5d46f..010ede0 100644 --- a/core/modules/block_content/src/BlockContentViewsData.php +++ b/core/modules/block_content/src/BlockContentViewsData.php @@ -23,13 +23,13 @@ public function getViewsData() { $data['block_content_field_data']['type']['field']['id'] = 'field'; - $data['block_content']['block_content_listing_empty'] = array( + $data['block_content']['block_content_listing_empty'] = [ 'title' => $this->t('Empty block library behavior'), 'help' => $this->t('Provides a link to add a new block.'), - 'area' => array( + 'area' => [ 'id' => 'block_content_listing_empty', - ), - ); + ], + ]; // Advertise this table as a possible base table. $data['block_content_field_revision']['table']['base']['help'] = $this->t('Block Content revision is a history of changes to block content.'); $data['block_content_field_revision']['table']['base']['defaults']['title'] = 'info'; diff --git a/core/modules/block_content/src/Controller/BlockContentController.php b/core/modules/block_content/src/Controller/BlockContentController.php index 1caad74..7c1f8aa 100644 --- a/core/modules/block_content/src/Controller/BlockContentController.php +++ b/core/modules/block_content/src/Controller/BlockContentController.php @@ -79,14 +79,14 @@ public function add(Request $request) { return $this->addForm($type, $request); } if (count($types) === 0) { - return array( + return [ '#markup' => $this->t('You have not created any block types yet. Go to the block type creation page to add a new block type.', [ ':url' => Url::fromRoute('block_content.type_add')->toString(), ]), - ); + ]; } - return array('#theme' => 'block_content_add_list', '#content' => $types); + return ['#theme' => 'block_content_add_list', '#content' => $types]; } /** @@ -101,9 +101,9 @@ public function add(Request $request) { * A form array as expected by drupal_render(). */ public function addForm(BlockContentTypeInterface $block_content_type, Request $request) { - $block = $this->blockContentStorage->create(array( + $block = $this->blockContentStorage->create([ 'type' => $block_content_type->id() - )); + ]); if (($theme = $request->query->get('theme')) && in_array($theme, array_keys($this->themeHandler->listInfo()))) { // We have navigated to this page from the block library and will keep track // of the theme for redirecting the user to the configuration page for the @@ -123,7 +123,7 @@ public function addForm(BlockContentTypeInterface $block_content_type, Request $ * The page title. */ public function getAddFormTitle(BlockContentTypeInterface $block_content_type) { - return $this->t('Add %type custom block', array('%type' => $block_content_type->label())); + return $this->t('Add %type custom block', ['%type' => $block_content_type->label()]); } } diff --git a/core/modules/block_content/src/Entity/BlockContent.php b/core/modules/block_content/src/Entity/BlockContent.php index 7c06ed8..11c0c54 100644 --- a/core/modules/block_content/src/Entity/BlockContent.php +++ b/core/modules/block_content/src/Entity/BlockContent.php @@ -126,7 +126,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti * {@inheritdoc} */ public function getInstances() { - return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(array('plugin' => 'block_content:' . $this->uuid())); + return \Drupal::entityTypeManager()->getStorage('block')->loadByProperties(['plugin' => 'block_content:' . $this->uuid()]); } /** @@ -178,10 +178,10 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setRevisionable(TRUE) ->setTranslatable(TRUE) ->setRequired(TRUE) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textfield', 'weight' => -5, - )) + ]) ->setDisplayConfigurable('form', TRUE) ->addConstraint('UniqueField', []); @@ -189,13 +189,13 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { ->setLabel(t('Revision log message')) ->setDescription(t('The log entry explaining the changes in this revision.')) ->setRevisionable(TRUE) - ->setDisplayOptions('form', array( + ->setDisplayOptions('form', [ 'type' => 'string_textarea', 'weight' => 25, - 'settings' => array( + 'settings' => [ 'rows' => 4, - ), - )); + ], + ]); $fields['changed'] = BaseFieldDefinition::create('changed') ->setLabel(t('Changed')) diff --git a/core/modules/block_content/src/Form/BlockContentDeleteForm.php b/core/modules/block_content/src/Form/BlockContentDeleteForm.php index 3fe725d..035ec4c 100644 --- a/core/modules/block_content/src/Form/BlockContentDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentDeleteForm.php @@ -16,10 +16,10 @@ class BlockContentDeleteForm extends ContentEntityDeleteForm { public function buildForm(array $form, FormStateInterface $form_state) { $instances = $this->entity->getInstances(); - $form['message'] = array( + $form['message'] = [ '#markup' => $this->formatPlural(count($instances), 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instances.'), '#access' => !empty($instances), - ); + ]; return parent::buildForm($form, $form_state); } diff --git a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php index b68e695..aea4ab5 100644 --- a/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php +++ b/core/modules/block_content/src/Form/BlockContentTypeDeleteForm.php @@ -18,8 +18,8 @@ public function buildForm(array $form, FormStateInterface $form_state) { ->condition('type', $this->entity->id()) ->execute(); if (!empty($blocks)) { - $caption = '' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', array('%label' => $this->entity->label())) . '
'; - $form['description'] = array('#markup' => $caption); + $caption = '' . $this->formatPlural(count($blocks), '%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', '%label is used by @count custom blocks on your site. You may not remove %label until you have removed all of the %label custom blocks.', ['%label' => $this->entity->label()]) . '
'; + $form['description'] = ['#markup' => $caption]; return $form; } else { diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 2afd040..e97e740 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -105,11 +105,11 @@ public static function create(ContainerInterface $container, array $configuratio * {@inheritdoc} */ public function defaultConfiguration() { - return array( + return [ 'status' => TRUE, 'info' => '', 'view_mode' => 'full', - ); + ]; } /** @@ -122,14 +122,14 @@ public function blockForm($form, FormStateInterface $form_state) { $block = $this->entityManager->loadEntityByUuid('block_content', $uuid); $options = $this->entityManager->getViewModeOptionsByBundle('block_content', $block->bundle()); - $form['view_mode'] = array( + $form['view_mode'] = [ '#type' => 'select', '#options' => $options, '#title' => $this->t('View mode'), '#description' => $this->t('Output the block in this view mode.'), '#default_value' => $this->configuration['view_mode'], '#access' => (count($options) > 1), - ); + ]; $form['title']['#description'] = $this->t('The title of the block as shown to the user.'); return $form; } @@ -161,13 +161,13 @@ public function build() { return $this->entityManager->getViewBuilder($block->getEntityTypeId())->view($block, $this->configuration['view_mode']); } else { - return array( - '#markup' => $this->t('Block with uuid %uuid does not exist. Add custom block.', array( + return [ + '#markup' => $this->t('Block with uuid %uuid does not exist. Add custom block.', [ '%uuid' => $this->getDerivativeId(), ':url' => $this->urlGenerator->generate('block_content.add_page') - )), + ]), '#access' => $this->account->hasPermission('administer blocks') - ); + ]; } } diff --git a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php index ab56445..25806c5 100644 --- a/core/modules/block_content/src/Plugin/Derivative/BlockContent.php +++ b/core/modules/block_content/src/Plugin/Derivative/BlockContent.php @@ -50,9 +50,9 @@ public function getDerivativeDefinitions($base_plugin_definition) { foreach ($block_contents as $block_content) { $this->derivatives[$block_content->uuid()] = $base_plugin_definition; $this->derivatives[$block_content->uuid()]['admin_label'] = $block_content->label(); - $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = array( + $this->derivatives[$block_content->uuid()]['config_dependencies']['content'] = [ $block_content->getConfigDependencyName() - ); + ]; } return parent::getDerivativeDefinitions($base_plugin_definition); } diff --git a/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php b/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php index 4135233..a28927b 100644 --- a/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php +++ b/core/modules/block_content/src/Plugin/migrate/source/d6/Box.php @@ -18,7 +18,7 @@ class Box extends DrupalSqlBase { */ public function query() { $query = $this->select('boxes', 'b') - ->fields('b', array('bid', 'body', 'info', 'format')); + ->fields('b', ['bid', 'body', 'info', 'format']); $query->orderBy('b.bid'); return $query; @@ -28,12 +28,12 @@ public function query() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'bid' => $this->t('The numeric identifier of the block/box'), 'body' => $this->t('The block/box content'), 'info' => $this->t('Admin title of the block/box.'), 'format' => $this->t('Input format of the custom block/box content.'), - ); + ]; } /** diff --git a/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php b/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php index 4aee2a4..ea33682 100644 --- a/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php +++ b/core/modules/block_content/src/Plugin/migrate/source/d7/BlockCustom.php @@ -24,12 +24,12 @@ public function query() { * {@inheritdoc} */ public function fields() { - return array( + return [ 'bid' => $this->t('The numeric identifier of the block/box'), 'body' => $this->t('The block/box content'), 'info' => $this->t('Admin title of the block/box.'), 'format' => $this->t('Input format of the custom block/box content.'), - ); + ]; } /** diff --git a/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php b/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php index d2bd026..e412f18 100644 --- a/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php +++ b/core/modules/block_content/src/Plugin/views/area/ListingEmpty.php @@ -71,19 +71,19 @@ public static function create(ContainerInterface $container, array $configuratio public function render($empty = FALSE) { if (!$empty || !empty($this->options['empty'])) { /** @var \Drupal\Core\Access\AccessResultInterface|\Drupal\Core\Cache\CacheableDependencyInterface $access_result */ - $access_result = $this->accessManager->checkNamedRoute('block_content.add_page', array(), $this->currentUser, TRUE); - $element = array( - '#markup' => $this->t('Add a custom block.', array(':url' => Url::fromRoute('block_content.add_page')->toString())), + $access_result = $this->accessManager->checkNamedRoute('block_content.add_page', [], $this->currentUser, TRUE); + $element = [ + '#markup' => $this->t('Add a custom block.', [':url' => Url::fromRoute('block_content.add_page')->toString()]), '#access' => $access_result->isAllowed(), '#cache' => [ 'contexts' => $access_result->getCacheContexts(), 'tags' => $access_result->getCacheTags(), 'max-age' => $access_result->getCacheMaxAge(), ], - ); + ]; return $element; } - return array(); + return []; } } diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php index e45892c..ac9e824 100644 --- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -21,17 +21,17 @@ class BlockContentCreationTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block_content_test', 'dblog', 'field_ui'); + public static $modules = ['block_content_test', 'dblog', 'field_ui']; /** * Permissions to grant admin user. * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks', 'administer block_content display' - ); + ]; /** * Sets the test up. @@ -48,22 +48,22 @@ public function testBlockContentCreation() { $this->drupalLogin($this->adminUser); // Create a block. - $edit = array(); + $edit = []; $edit['info[0][value]'] = 'Test Block'; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('@block %name has been created.', array( + $this->assertRaw(format_string('@block %name has been created.', [ '@block' => 'basic', '%name' => $edit['info[0][value]'] - )), 'Basic block created.'); + ]), 'Basic block created.'); // Check that the view mode setting is hidden because only one exists. $this->assertNoFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting hidden because only one exists'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); @@ -72,9 +72,9 @@ public function testBlockContentCreation() { $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('A custom block with block description %value already exists.', array( + $this->assertRaw(format_string('A custom block with block description %value already exists.', [ '%value' => $edit['info[0][value]'] - ))); + ])); $this->assertResponse(200); } @@ -83,28 +83,28 @@ public function testBlockContentCreation() { */ public function testBlockContentCreationMultipleViewModes() { // Add a new view mode and verify if it is selected as expected. - $this->drupalLogin($this->drupalCreateUser(array('administer display modes'))); + $this->drupalLogin($this->drupalCreateUser(['administer display modes'])); $this->drupalGet('admin/structure/display-modes/view/add/block_content'); - $edit = array( + $edit = [ 'id' => 'test_view_mode', 'label' => 'Test View Mode', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); - $this->assertRaw(t('Saved the %label view mode.', array('%label' => $edit['label']))); + $this->assertRaw(t('Saved the %label view mode.', ['%label' => $edit['label']])); $this->drupalLogin($this->adminUser); // Create a block. - $edit = array(); + $edit = []; $edit['info[0][value]'] = 'Test Block'; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('@block %name has been created.', array( + $this->assertRaw(format_string('@block %name has been created.', [ '@block' => 'basic', '%name' => $edit['info[0][value]'] - )), 'Basic block created.'); + ]), 'Basic block created.'); // Save our block permanently $this->drupalPostForm(NULL, ['region' => 'content'], t('Save block')); @@ -114,9 +114,9 @@ public function testBlockContentCreationMultipleViewModes() { $this->drupalGet('admin/structure/block/block-content/types'); $this->clickLink(t('Manage display')); $this->drupalGet('admin/structure/block/block-content/manage/basic/display'); - $custom_view_mode = array( + $custom_view_mode = [ 'display_modes_custom[test_view_mode]' => 1, - ); + ]; $this->drupalPostForm(NULL, $custom_view_mode, t('Save')); // Go to the configure page and change the view mode. @@ -143,7 +143,7 @@ public function testBlockContentCreationMultipleViewModes() { $this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); $block = reset($blocks); $this->assertTrue($block, 'Custom Block found in database.'); @@ -152,9 +152,9 @@ public function testBlockContentCreationMultipleViewModes() { $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Check that the Basic block has been created. - $this->assertRaw(format_string('A custom block with block description %value already exists.', array( + $this->assertRaw(format_string('A custom block with block description %value already exists.', [ '%value' => $edit['info[0][value]'] - ))); + ])); $this->assertResponse(200); } @@ -165,20 +165,20 @@ public function testBlockContentCreationMultipleViewModes() { * type is being used. */ public function testDefaultBlockContentCreation() { - $edit = array(); + $edit = []; $edit['info[0][value]'] = $this->randomMachineName(8); $edit['body[0][value]'] = $this->randomMachineName(16); // Don't pass the custom block type in the url so the default is forced. $this->drupalPostForm('block/add', $edit, t('Save')); // Check that the block has been created and that it is a basic block. - $this->assertRaw(format_string('@block %name has been created.', array( + $this->assertRaw(format_string('@block %name has been created.', [ '@block' => 'basic', '%name' => $edit['info[0][value]'], - )), 'Basic block created.'); + ]), 'Basic block created.'); // Check that the block exists in the database. - $blocks = entity_load_multiple_by_properties('block_content', array('info' => $edit['info[0][value]'])); + $blocks = entity_load_multiple_by_properties('block_content', ['info' => $edit['info[0][value]']]); $block = reset($blocks); $this->assertTrue($block, 'Default Custom Block found in database.'); } @@ -199,7 +199,7 @@ public function testFailedBlockCreation() { if (Database::getConnection()->supportsTransactions()) { // Check that the block does not exist in the database. $id = db_select('block_content_field_data', 'b') - ->fields('b', array('id')) + ->fields('b', ['id']) ->condition('info', 'fail_creation') ->execute() ->fetchField(); @@ -208,7 +208,7 @@ public function testFailedBlockCreation() { else { // Check that the block exists in the database. $id = db_select('block_content_field_data', 'b') - ->fields('b', array('id')) + ->fields('b', ['id']) ->condition('info', 'fail_creation') ->execute() ->fetchField(); @@ -225,18 +225,18 @@ public function testFailedBlockCreation() { */ public function testBlockDelete() { // Create a block. - $edit = array(); + $edit = []; $edit['info[0][value]'] = $this->randomMachineName(8); $body = $this->randomMachineName(16); $edit['body[0][value]'] = $body; $this->drupalPostForm('block/add/basic', $edit, t('Save')); // Place the block. - $instance = array( + $instance = [ 'id' => Unicode::strtolower($edit['info[0][value]']), 'settings[label]' => $edit['info[0][value]'], 'region' => 'sidebar_first', - ); + ]; $block = BlockContent::load(1); $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); @@ -254,11 +254,11 @@ public function testBlockDelete() { $this->drupalGet('block/1/delete'); $this->assertText(\Drupal::translation()->formatPlural(1, 'This will also remove 1 placed block instance.', 'This will also remove @count placed block instance.')); - $this->drupalPostForm(NULL, array(), 'Delete'); - $this->assertRaw(t('The custom block %name has been deleted.', array('%name' => $edit['info[0][value]']))); + $this->drupalPostForm(NULL, [], 'Delete'); + $this->assertRaw(t('The custom block %name has been deleted.', ['%name' => $edit['info[0][value]']])); // Create another block and force the plugin cache to flush. - $edit2 = array(); + $edit2 = []; $edit2['info[0][value]'] = $this->randomMachineName(8); $body2 = $this->randomMachineName(16); $edit2['body[0][value]'] = $body2; @@ -268,7 +268,7 @@ public function testBlockDelete() { // Create another block with no instances, and test we don't get a // confirmation message about deleting instances. - $edit3 = array(); + $edit3 = []; $edit3['info[0][value]'] = $this->randomMachineName(8); $body = $this->randomMachineName(16); $edit3['body[0][value]'] = $body; @@ -286,16 +286,16 @@ public function testConfigDependencies() { $block = $this->createBlockContent(); // Place the block. $block_placement_id = Unicode::strtolower($block->label()); - $instance = array( + $instance = [ 'id' => $block_placement_id, 'settings[label]' => $block->label(), 'region' => 'sidebar_first', - ); + ]; $block = BlockContent::load(1); $url = 'admin/structure/block/add/block_content:' . $block->uuid() . '/' . $this->config('system.theme')->get('default'); $this->drupalPostForm($url, $instance, t('Save block')); - $dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', array($block->getConfigDependencyName())); + $dependencies = \Drupal::service('config.manager')->findConfigEntityDependentsAsEntities('content', [$block->getConfigDependencyName()]); $block_placement = reset($dependencies); $this->assertEqual($block_placement_id, $block_placement->id(), "The block placement config entity has a dependency on the block content entity."); } diff --git a/core/modules/block_content/src/Tests/BlockContentListTest.php b/core/modules/block_content/src/Tests/BlockContentListTest.php index be8ea5e..e00706e 100644 --- a/core/modules/block_content/src/Tests/BlockContentListTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListTest.php @@ -18,13 +18,13 @@ class BlockContentListTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block', 'block_content', 'config_translation'); + public static $modules = ['block', 'block_content', 'config_translation']; /** * Tests the custom block listing page. */ public function testListing() { - $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); + $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration'])); $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. @@ -39,7 +39,7 @@ public function testListing() { $this->assertEqual(count($elements), 2, 'Correct number of table header cells found.'); // Test the contents of each th cell. - $expected_items = array(t('Block description'), t('Operations')); + $expected_items = [t('Block description'), t('Operations')]; foreach ($elements as $key => $element) { $this->assertEqual($element[0], $expected_items[$key]); } @@ -51,7 +51,7 @@ public function testListing() { $this->assertLink($link_text); $this->clickLink($link_text); $this->assertResponse(200); - $edit = array(); + $edit = []; $edit['info[0][value]'] = $label; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -72,14 +72,14 @@ public function testListing() { $blocks = $this->container ->get('entity.manager') ->getStorage('block_content') - ->loadByProperties(array('info' => $label)); + ->loadByProperties(['info' => $label]); $block = reset($blocks); if (!empty($block)) { $this->assertLinkByHref('block/' . $block->id()); $this->clickLink(t('Edit')); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Edit custom block %label', array('%label' => $label)) . ' | Drupal')); - $edit = array('info[0][value]' => $new_label); + $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal')); + $edit = ['info[0][value]' => $new_label]; $this->drupalPostForm(NULL, $edit, t('Save')); } else { @@ -95,8 +95,8 @@ public function testListing() { $delete_text = t('Delete'); $this->clickLink($delete_text); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', array('%label' => $new_label)) . ' | Drupal')); - $this->drupalPostForm(NULL, array(), $delete_text); + $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal')); + $this->drupalPostForm(NULL, [], $delete_text); // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). diff --git a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php index de0ff3b..77117fb 100644 --- a/core/modules/block_content/src/Tests/BlockContentListViewsTest.php +++ b/core/modules/block_content/src/Tests/BlockContentListViewsTest.php @@ -22,7 +22,7 @@ class BlockContentListViewsTest extends BlockContentTestBase { * Tests the custom block listing page. */ public function testListing() { - $this->drupalLogin($this->drupalCreateUser(array('administer blocks', 'translate configuration'))); + $this->drupalLogin($this->drupalCreateUser(['administer blocks', 'translate configuration'])); $this->drupalGet('admin/structure/block/block-content'); // Test for the page title. @@ -58,7 +58,7 @@ public function testListing() { $this->assertLink($link_text); $this->clickLink($link_text); $this->assertResponse(200); - $edit = array(); + $edit = []; $edit['info[0][value]'] = $label; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -79,14 +79,14 @@ public function testListing() { $blocks = $this->container ->get('entity.manager') ->getStorage('block_content') - ->loadByProperties(array('info' => $label)); + ->loadByProperties(['info' => $label]); $block = reset($blocks); if (!empty($block)) { $this->assertLinkByHref('block/' . $block->id()); $this->clickLink(t('Edit')); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Edit custom block %label', array('%label' => $label)) . ' | Drupal')); - $edit = array('info[0][value]' => $new_label); + $this->assertTitle(strip_tags(t('Edit custom block %label', ['%label' => $label]) . ' | Drupal')); + $edit = ['info[0][value]' => $new_label]; $this->drupalPostForm(NULL, $edit, t('Save')); } else { @@ -102,8 +102,8 @@ public function testListing() { $delete_text = t('Delete'); $this->clickLink($delete_text); $this->assertResponse(200); - $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', array('%label' => $new_label)) . ' | Drupal')); - $this->drupalPostForm(NULL, array(), $delete_text); + $this->assertTitle(strip_tags(t('Are you sure you want to delete the custom block %label?', ['%label' => $new_label]) . ' | Drupal')); + $this->drupalPostForm(NULL, [], $delete_text); // Verify that the text of the label and machine name does not appear in // the list (though it may appear elsewhere on the page). diff --git a/core/modules/block_content/src/Tests/BlockContentTestBase.php b/core/modules/block_content/src/Tests/BlockContentTestBase.php index 28c6e22..3794478 100644 --- a/core/modules/block_content/src/Tests/BlockContentTestBase.php +++ b/core/modules/block_content/src/Tests/BlockContentTestBase.php @@ -31,16 +31,16 @@ * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks' - ); + ]; /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'block_content'); + public static $modules = ['block', 'block_content']; /** * Whether or not to auto-create the basic block type during setup. @@ -78,11 +78,11 @@ protected function setUp() { */ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) { $title = $title ?: $this->randomMachineName(); - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en' - )); + ]); if ($block_content && $save === TRUE) { $block_content->save(); } @@ -101,11 +101,11 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = * Created custom block type. */ protected function createBlockContentType($label, $create_body = FALSE) { - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $label, 'label' => $label, 'revision' => FALSE, - )); + ]); $bundle->save(); if ($create_body) { block_content_add_body_field($bundle->id()); diff --git a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php index 332bf3d..198beee 100644 --- a/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php +++ b/core/modules/block_content/src/Tests/BlockContentTranslationUITest.php @@ -19,13 +19,13 @@ class BlockContentTranslationUITest extends ContentTranslationUITestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'language', 'content_translation', 'block', 'field_ui', 'block_content' - ); + ]; /** * {@inheritdoc} @@ -57,11 +57,11 @@ protected function setUp() { */ protected function setupBundle() { // Create the basic bundle since it is provided by standard. - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $this->bundle, 'label' => $this->bundle, 'revision' => FALSE - )); + ]); $bundle->save(); } @@ -69,12 +69,12 @@ protected function setupBundle() { * {@inheritdoc} */ public function getTranslatorPermissions() { - return array_merge(parent::getTranslatorPermissions(), array( + return array_merge(parent::getTranslatorPermissions(), [ 'translate any entity', 'access administration pages', 'administer blocks', 'administer block_content fields' - )); + ]); } /** @@ -93,11 +93,11 @@ public function getTranslatorPermissions() { protected function createBlockContent($title = FALSE, $bundle = FALSE) { $title = $title ?: $this->randomMachineName(); $bundle = $bundle ?: $this->bundle; - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en' - )); + ]); $block_content->save(); return $block_content; } @@ -106,7 +106,7 @@ protected function createBlockContent($title = FALSE, $bundle = FALSE) { * {@inheritdoc} */ protected function getNewEntityValues($langcode) { - return array('info' => Unicode::strtolower($this->randomMachineName())) + parent::getNewEntityValues($langcode); + return ['info' => Unicode::strtolower($this->randomMachineName())] + parent::getNewEntityValues($langcode); } /** @@ -135,7 +135,7 @@ protected function doTestBasicTranslation() { $values = $this->getNewEntityValues($default_langcode); $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */ - $entity = $storage->create(array('type' => 'basic') + $values); + $entity = $storage->create(['type' => 'basic'] + $values); $entity->save(); $entity->addTranslation('it', $values); @@ -159,11 +159,11 @@ protected function doTestBasicTranslation() { public function testDisabledBundle() { // Create a bundle that does not have translation enabled. $disabled_bundle = $this->randomMachineName(); - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $disabled_bundle, 'label' => $disabled_bundle, 'revision' => FALSE - )); + ]); $bundle->save(); // Create a block content for each bundle. @@ -171,7 +171,7 @@ public function testDisabledBundle() { $disabled_block_content = $this->createBlockContent(FALSE, $bundle->id()); // Make sure that only a single row was inserted into the block table. - $rows = db_query('SELECT * FROM {block_content_field_data} WHERE id = :id', array(':id' => $enabled_block_content->id()))->fetchAll(); + $rows = db_query('SELECT * FROM {block_content_field_data} WHERE id = :id', [':id' => $enabled_block_content->id()])->fetchAll(); $this->assertEqual(1, count($rows)); } @@ -188,15 +188,15 @@ protected function doTestTranslationEdit() { foreach ($this->langcodes as $langcode) { // We only want to test the title for non-english translations. if ($langcode != 'en') { - $options = array('language' => $languages[$langcode]); + $options = ['language' => $languages[$langcode]]; $url = $entity->urlInfo('edit-form', $options); $this->drupalGet($url); - $title = t('Edit @type @title [%language translation]', array( + $title = t('Edit @type @title [%language translation]', [ '@type' => $entity->bundle(), '@title' => $entity->getTranslation($langcode)->label(), '%language' => $languages[$langcode]->getName(), - )); + ]); $this->assertRaw($title); } } diff --git a/core/modules/block_content/src/Tests/BlockContentTypeTest.php b/core/modules/block_content/src/Tests/BlockContentTypeTest.php index 8f6ffe1..e69394b 100644 --- a/core/modules/block_content/src/Tests/BlockContentTypeTest.php +++ b/core/modules/block_content/src/Tests/BlockContentTypeTest.php @@ -17,17 +17,17 @@ class BlockContentTypeTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('field_ui'); + public static $modules = ['field_ui']; /** * Permissions to grant admin user. * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks', 'administer block_content fields' - ); + ]; /** * Whether or not to create an initial block type. @@ -56,10 +56,10 @@ public function testBlockContentTypeCreation() { $this->clickLink('block type creation page'); // Create a block type via the user interface. - $edit = array( + $edit = [ 'id' => 'foo', 'label' => 'title for foo', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); $block_type = BlockContentType::load('foo'); $this->assertTrue($block_type, 'The new block type has been created.'); @@ -107,9 +107,9 @@ public function testBlockContentTypeEditing() { $this->assertRaw('Body', 'Body field was found.'); // Change the block type name. - $edit = array( + $edit = [ 'label' => 'Bar', - ); + ]; $this->drupalGet('admin/structure/block/block-content/manage/basic'); $this->assertTitle(format_string('Edit @type custom block type | Drupal', ['@type' => 'basic'])); $this->drupalPostForm(NULL, $edit, t('Save')); @@ -121,9 +121,9 @@ public function testBlockContentTypeEditing() { $this->assertUrl(\Drupal::url('block_content.add_form', ['block_content_type' => 'basic'], ['absolute' => TRUE]), [], 'Original machine name was used in URL.'); // Remove the body field. - $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic/fields/block_content.basic.body/delete', [], t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/block/block-content/manage/basic', array(), t('Save')); + $this->drupalPostForm('admin/structure/block/block-content/manage/basic', [], t('Save')); // Check that the body field doesn't exist. $this->drupalGet('block/add/basic'); $this->assertNoRaw('Body', 'Body field was not found.'); @@ -146,7 +146,7 @@ public function testBlockContentTypeDeletion() { // Attempt to delete the block type, which should not be allowed. $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( - t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', array('%label' => $type->label())), + t('%label is used by 1 custom block on your site. You can not remove this block type until you have removed all of the %label blocks.', ['%label' => $type->label()]), 'The block type will not be deleted until all blocks of that type are removed.' ); $this->assertNoText(t('This action cannot be undone.'), 'The block type deletion confirmation form is not available.'); @@ -156,7 +156,7 @@ public function testBlockContentTypeDeletion() { // Attempt to delete the block type, which should now be allowed. $this->drupalGet('admin/structure/block/block-content/manage/' . $type->id() . '/delete'); $this->assertRaw( - t('Are you sure you want to delete the custom block type %type?', array('%type' => $type->id())), + t('Are you sure you want to delete the custom block type %type?', ['%type' => $type->id()]), 'The block type is available for deletion.' ); $this->assertText(t('This action cannot be undone.'), 'The custom block type deletion confirmation form is available.'); @@ -197,22 +197,22 @@ public function testsBlockContentAddTypes() { $this->clickLink(t('Add custom block')); // The seven theme has markup inside the link, we cannot use clickLink(). if ($default_theme == 'seven') { - $options = $theme != $default_theme ? array('query' => array('theme' => $theme)) : array(); - $this->assertLinkByHref(\Drupal::url('block_content.add_form', array('block_content_type' => 'foo'), $options)); + $options = $theme != $default_theme ? ['query' => ['theme' => $theme]] : []; + $this->assertLinkByHref(\Drupal::url('block_content.add_form', ['block_content_type' => 'foo'], $options)); $this->drupalGet('block/add/foo', $options); } else { $this->clickLink('foo'); } // Create a new block. - $edit = array('info[0][value]' => $this->randomMachineName(8)); + $edit = ['info[0][value]' => $this->randomMachineName(8)]; $this->drupalPostForm(NULL, $edit, t('Save')); - $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); + $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]); if (!empty($blocks)) { $block = reset($blocks); - $this->assertUrl(\Drupal::url('block.admin_add', array('plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme), array('absolute' => TRUE))); + $this->assertUrl(\Drupal::url('block.admin_add', ['plugin_id' => 'block_content:' . $block->uuid(), 'theme' => $theme], ['absolute' => TRUE])); $this->drupalPostForm(NULL, ['region' => 'content'], t('Save block')); - $this->assertUrl(\Drupal::url('block.admin_display_theme', array('theme' => $theme), array('absolute' => TRUE, 'query' => array('block-placement' => Html::getClass($edit['info[0][value]']))))); + $this->assertUrl(\Drupal::url('block.admin_display_theme', ['theme' => $theme], ['absolute' => TRUE, 'query' => ['block-placement' => Html::getClass($edit['info[0][value]'])]])); } else { $this->fail('Could not load created block.'); @@ -225,11 +225,11 @@ public function testsBlockContentAddTypes() { $this->drupalGet('admin/structure/block/block-content'); $this->clickLink(t('Add custom block')); $this->clickLink('foo'); - $edit = array('info[0][value]' => $this->randomMachineName(8)); + $edit = ['info[0][value]' => $this->randomMachineName(8)]; $this->drupalPostForm(NULL, $edit, t('Save')); - $blocks = $storage->loadByProperties(array('info' => $edit['info[0][value]'])); + $blocks = $storage->loadByProperties(['info' => $edit['info[0][value]']]); if (!empty($blocks)) { - $this->assertUrl(\Drupal::url('entity.block_content.collection', array(), array('absolute' => TRUE))); + $this->assertUrl(\Drupal::url('entity.block_content.collection', [], ['absolute' => TRUE])); } else { $this->fail('Could not load created block.'); diff --git a/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php b/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php index 5a46ddd..905a7a0 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentFieldFilterTest.php @@ -15,14 +15,14 @@ class BlockContentFieldFilterTest extends BlockContentTestBase { /** * {@inheritdoc} */ - public static $modules = array('language'); + public static $modules = ['language']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_field_filters'); + public static $testViews = ['test_field_filters']; /** * List of block_content infos by language. @@ -49,15 +49,15 @@ function setUp() { $field_storage->save(); // Set up block_content infos. - $this->blockContentInfos = array( + $this->blockContentInfos = [ 'en' => 'Food in Paris', 'es' => 'Comida en Paris', 'fr' => 'Nouriture en Paris', - ); + ]; // Create block_content with translations. $block_content = $this->createBlockContent(['info' => $this->blockContentInfos['en'], 'langcode' => 'en', 'type' => 'basic', 'body' => [['value' => $this->blockContentInfos['en']]]]); - foreach (array('es', 'fr') as $langcode) { + foreach (['es', 'fr'] as $langcode) { $translation = $block_content->addTranslation($langcode, ['info' => $this->blockContentInfos[$langcode]]); $translation->body->value = $this->blockContentInfos[$langcode]; } @@ -70,19 +70,19 @@ function setUp() { public function testFilters() { // Test the info filter page, which filters for info contains 'Comida'. // Should show just the Spanish translation, once. - $this->assertPageCounts('test-info-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida info filter'); + $this->assertPageCounts('test-info-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida info filter'); // Test the body filter page, which filters for body contains 'Comida'. // Should show just the Spanish translation, once. - $this->assertPageCounts('test-body-filter', array('es' => 1, 'fr' => 0, 'en' => 0), 'Comida body filter'); + $this->assertPageCounts('test-body-filter', ['es' => 1, 'fr' => 0, 'en' => 0], 'Comida body filter'); // Test the info Paris filter page, which filters for info contains // 'Paris'. Should show each translation once. - $this->assertPageCounts('test-info-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris info filter'); + $this->assertPageCounts('test-info-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris info filter'); // Test the body Paris filter page, which filters for body contains // 'Paris'. Should show each translation once. - $this->assertPageCounts('test-body-paris', array('es' => 1, 'fr' => 1, 'en' => 1), 'Paris body filter'); + $this->assertPageCounts('test-body-paris', ['es' => 1, 'fr' => 1, 'en' => 1], 'Paris body filter'); } /** diff --git a/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php b/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php index d92c5be..8ec17e2 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentIntegrationTest.php @@ -14,23 +14,23 @@ class BlockContentIntegrationTest extends BlockContentTestBase { * * @var array */ - public static $testViews = array('test_block_content_view'); + public static $testViews = ['test_block_content_view']; /** * Tests basic block_content view with a block_content_type argument. */ public function testBlockContentViewTypeArgument() { // Create two content types with three block_contents each. - $types = array(); - $all_ids = array(); - $block_contents = array(); + $types = []; + $all_ids = []; + $block_contents = []; for ($i = 0; $i < 2; $i++) { $type = $this->createBlockContentType(); $types[] = $type; for ($j = 0; $j < 5; $j++) { // Ensure the right order of the block_contents. - $block_content = $this->createBlockContent(array('type' => $type->id())); + $block_content = $this->createBlockContent(['type' => $type->id()]); $block_contents[$type->id()][$block_content->id()] = $block_content; $all_ids[] = $block_content->id(); } @@ -55,9 +55,9 @@ public function testBlockContentViewTypeArgument() { * @param array $expected_ids * An array of block_content IDs. */ - protected function assertIds(array $expected_ids = array()) { + protected function assertIds(array $expected_ids = []) { $result = $this->xpath('//span[@class="field-content"]'); - $ids = array(); + $ids = []; foreach ($result as $element) { $ids[] = (int) $element; } diff --git a/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php b/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php index ff80665..828aa84 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentRedirectTest.php @@ -21,18 +21,18 @@ class BlockContentRedirectTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block', 'block_content', 'views'); + public static $modules = ['block', 'block_content', 'views']; /** * Tests the redirect destination when editing block content. */ public function testRedirectDestination() { - $this->drupalLogin($this->drupalCreateUser(array('administer blocks'))); + $this->drupalLogin($this->drupalCreateUser(['administer blocks'])); $this->drupalGet('admin/structure/block/block-content'); // Create a custom block. $this->clickLink('custom block'); - $edit = array(); + $edit = []; $edit['info[0][value]'] = 'Test redirect destination'; $edit['body[0][value]'] = $this->randomMachineName(16); $this->drupalPostForm(NULL, $edit, 'Save'); diff --git a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php index 65d33c88..db665c9 100644 --- a/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php +++ b/core/modules/block_content/src/Tests/Views/BlockContentTestBase.php @@ -25,26 +25,26 @@ * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks', - ); + ]; /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'block_content', 'block_content_test_views'); + public static $modules = ['block', 'block_content', 'block_content_test_views']; protected function setUp($import_test_views = TRUE) { parent::setUp($import_test_views); // Ensure the basic bundle exists. This is provided by the standard profile. - $this->createBlockContentType(array('id' => 'basic')); + $this->createBlockContentType(['id' => 'basic']); $this->adminUser = $this->drupalCreateUser($this->permissions); if ($import_test_views) { - ViewTestData::createTestViews(get_class($this), array('block_content_test_views')); + ViewTestData::createTestViews(get_class($this), ['block_content_test_views']); } } @@ -58,17 +58,17 @@ protected function setUp($import_test_views = TRUE) { * @return \Drupal\block_content\Entity\BlockContent * Created custom block. */ - protected function createBlockContent(array $settings = array()) { + protected function createBlockContent(array $settings = []) { $status = 0; - $settings += array( + $settings += [ 'info' => $this->randomMachineName(), 'type' => 'basic', 'langcode' => 'en', - ); + ]; if ($block_content = BlockContent::create($settings)) { $status = $block_content->save(); } - $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', array('%info' => $block_content->label()))); + $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content %info.', ['%info' => $block_content->label()])); return $block_content; } @@ -81,7 +81,7 @@ protected function createBlockContent(array $settings = array()) { * @return \Drupal\block_content\Entity\BlockContentType * Created custom block type. */ - protected function createBlockContentType(array $values = array()) { + protected function createBlockContentType(array $values = []) { // Find a non-existent random type name. if (!isset($values['id'])) { do { @@ -91,16 +91,16 @@ protected function createBlockContentType(array $values = array()) { else { $id = $values['id']; } - $values += array( + $values += [ 'id' => $id, 'label' => $id, 'revision' => FALSE - ); + ]; $bundle = BlockContentType::create($values); $status = $bundle->save(); block_content_add_body_field($bundle->id()); - $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', array('%bundle' => $bundle->id()))); + $this->assertEqual($status, SAVED_NEW, SafeMarkup::format('Created block content type %bundle.', ['%bundle' => $bundle->id()])); return $bundle; } diff --git a/core/modules/block_content/src/Tests/Views/FieldTypeTest.php b/core/modules/block_content/src/Tests/Views/FieldTypeTest.php index f14653f..e9aa336 100644 --- a/core/modules/block_content/src/Tests/Views/FieldTypeTest.php +++ b/core/modules/block_content/src/Tests/Views/FieldTypeTest.php @@ -16,18 +16,18 @@ class FieldTypeTest extends BlockContentTestBase { * * @var array */ - public static $testViews = array('test_field_type'); + public static $testViews = ['test_field_type']; public function testFieldType() { $block_content = $this->createBlockContent(); - $expected_result[] = array( + $expected_result[] = [ 'id' => $block_content->id(), 'type' => $block_content->bundle(), - ); - $column_map = array( + ]; + $column_map = [ 'id' => 'id', 'type:target_id' => 'type', - ); + ]; $view = Views::getView('test_field_type'); $this->executeView($view); diff --git a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php index 516705d..7bad093 100644 --- a/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php +++ b/core/modules/block_content/src/Tests/Views/RevisionRelationshipsTest.php @@ -20,72 +20,72 @@ class RevisionRelationshipsTest extends ViewTestBase { * * @var array */ - public static $modules = array('block_content' , 'block_content_test_views'); + public static $modules = ['block_content' , 'block_content_test_views']; /** * Views used by this test. * * @var array */ - public static $testViews = array('test_block_content_revision_id', 'test_block_content_revision_revision_id'); + public static $testViews = ['test_block_content_revision_id', 'test_block_content_revision_revision_id']; protected function setUp() { parent::setUp(); - BlockContentType::create(array( + BlockContentType::create([ 'id' => 'basic', 'label' => 'basic', 'revision' => TRUE, - )); - ViewTestData::createTestViews(get_class($this), array('block_content_test_views')); + ]); + ViewTestData::createTestViews(get_class($this), ['block_content_test_views']); } /** * Create a block_content with revision and rest result count for both views. */ public function testBlockContentRevisionRelationship() { - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $this->randomMachineName(), 'type' => 'basic', 'langcode' => 'en', - )); + ]); $block_content->save(); // Create revision of the block_content. $block_content_revision = clone $block_content; $block_content_revision->setNewRevision(); $block_content_revision->save(); - $column_map = array( + $column_map = [ 'revision_id' => 'revision_id', 'id_1' => 'id_1', 'block_content_field_data_block_content_field_revision_id' => 'block_content_field_data_block_content_field_revision_id', - ); + ]; // Here should be two rows. $view_id = Views::getView('test_block_content_revision_id'); - $this->executeView($view_id, array($block_content->id())); - $resultset_id = array( - array( + $this->executeView($view_id, [$block_content->id()]); + $resultset_id = [ + [ 'revision_id' => '1', 'id_1' => '1', 'block_content_field_data_block_content_field_revision_id' => '1', - ), - array( + ], + [ 'revision_id' => '2', 'id_1' => '1', 'block_content_field_data_block_content_field_revision_id' => '1', - ), - ); + ], + ]; $this->assertIdenticalResultset($view_id, $resultset_id, $column_map); // There should be only one row with active revision 2. $view_revision_id = Views::getView('test_block_content_revision_revision_id'); - $this->executeView($view_revision_id, array($block_content->id())); - $resultset_revision_id = array( - array( + $this->executeView($view_revision_id, [$block_content->id()]); + $resultset_revision_id = [ + [ 'revision_id' => '2', 'id_1' => '1', 'block_content_field_data_block_content_field_revision_id' => '1', - ), - ); + ], + ]; $this->assertIdenticalResultset($view_revision_id, $resultset_revision_id, $column_map); } diff --git a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module index 57ea2a6..0489a61 100644 --- a/core/modules/block_content/tests/modules/block_content_test/block_content_test.module +++ b/core/modules/block_content/tests/modules/block_content_test/block_content_test.module @@ -15,9 +15,9 @@ */ function block_content_test_block_content_view(array &$build, BlockContent $block_content, $view_mode) { // Add extra content. - $build['extra_content'] = array( + $build['extra_content'] = [ '#markup' => '', - ); + ]; } /** diff --git a/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php index f44a773..e00de6b 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentCacheTagsTest.php @@ -20,29 +20,29 @@ class BlockContentCacheTagsTest extends EntityCacheTagsTestBase { /** * {@inheritdoc} */ - public static $modules = array('block_content'); + public static $modules = ['block_content']; /** * {@inheritdoc} */ protected function createEntity() { - $block_content_type = BlockContentType::create(array( + $block_content_type = BlockContentType::create([ 'id' => 'basic', 'label' => 'basic', 'revision' => FALSE - )); + ]); $block_content_type->save(); block_content_add_body_field($block_content_type->id()); // Create a "Llama" custom block. - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => 'Llama', 'type' => 'basic', - 'body' => array( + 'body' => [ 'value' => 'The name "llama" was adopted by European settlers from native Peruvians.', 'format' => 'plain_text', - ), - )); + ], + ]); $block_content->save(); return $block_content; diff --git a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php index 8c55da3..355faf1 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentPageViewTest.php @@ -14,7 +14,7 @@ class BlockContentPageViewTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block_content_test'); + public static $modules = ['block_content_test']; /** * Checks block edit and fallback functionality. diff --git a/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php b/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php index 33f75ed..fa88c64 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentRevisionsTest.php @@ -37,8 +37,8 @@ protected function setUp() { // Create initial block. $block = $this->createBlockContent('initial'); - $blocks = array(); - $logs = array(); + $blocks = []; + $logs = []; // Get original block. $blocks[] = $block->getRevisionId(); @@ -74,9 +74,9 @@ public function testRevisions() { ->getStorage('block_content') ->loadRevision($revision_id); // Verify revision log is the same. - $this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', array( + $this->assertEqual($loaded->getRevisionLogMessage(), $logs[$delta], format_string('Correct log message found for revision @revision', [ '@revision' => $loaded->getRevisionId(), - ))); + ])); if ($delta > 0) { $this->assertTrue($loaded->getRevisionUser() instanceof UserInterface, 'Revision User found.'); $this->assertTrue(is_numeric($loaded->getRevisionUserId()), 'Revision User ID found.'); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php b/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php index a68f423..0f7ae5a 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentSaveTest.php @@ -16,7 +16,7 @@ class BlockContentSaveTest extends BlockContentTestBase { * * @var array */ - public static $modules = array('block_content_test'); + public static $modules = ['block_content_test']; /** * Sets the test up. @@ -35,12 +35,12 @@ public function testImport() { $max_id = db_query('SELECT MAX(id) FROM {block_content}')->fetchField(); $test_id = $max_id + mt_rand(1000, 1000000); $info = $this->randomMachineName(8); - $block_array = array( + $block_array = [ 'info' => $info, - 'body' => array('value' => $this->randomMachineName(32)), + 'body' => ['value' => $this->randomMachineName(32)], 'type' => 'basic', 'id' => $test_id - ); + ]; $block = BlockContent::create($block_array); $block->enforceIsNew(TRUE); $block->save(); diff --git a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php index e5e7736..45c7e26 100644 --- a/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php +++ b/core/modules/block_content/tests/src/Functional/BlockContentTestBase.php @@ -28,16 +28,16 @@ * * @var array */ - protected $permissions = array( + protected $permissions = [ 'administer blocks' - ); + ]; /** * Modules to enable. * * @var array */ - public static $modules = array('block', 'block_content'); + public static $modules = ['block', 'block_content']; /** * Whether or not to auto-create the basic block type during setup. @@ -75,11 +75,11 @@ protected function setUp() { */ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = TRUE) { $title = $title ?: $this->randomMachineName(); - $block_content = BlockContent::create(array( + $block_content = BlockContent::create([ 'info' => $title, 'type' => $bundle, 'langcode' => 'en' - )); + ]); if ($block_content && $save === TRUE) { $block_content->save(); } @@ -98,11 +98,11 @@ protected function createBlockContent($title = FALSE, $bundle = 'basic', $save = * Created custom block type. */ protected function createBlockContentType($label, $create_body = FALSE) { - $bundle = BlockContentType::create(array( + $bundle = BlockContentType::create([ 'id' => $label, 'label' => $label, 'revision' => FALSE, - )); + ]); $bundle->save(); if ($create_body) { block_content_add_body_field($bundle->id()); diff --git a/core/modules/block_content/tests/src/Functional/PageEditTest.php b/core/modules/block_content/tests/src/Functional/PageEditTest.php index bab2a29..41638bd 100644 --- a/core/modules/block_content/tests/src/Functional/PageEditTest.php +++ b/core/modules/block_content/tests/src/Functional/PageEditTest.php @@ -27,7 +27,7 @@ public function testPageEdit() { $title_key = 'info[0][value]'; $body_key = 'body[0][value]'; // Create block to edit. - $edit = array(); + $edit = []; $edit['info[0][value]'] = Unicode::strtolower($this->randomMachineName(8)); $edit[$body_key] = $this->randomMachineName(16); $this->drupalPostForm('block/add/basic', $edit, t('Save')); @@ -43,7 +43,7 @@ public function testPageEdit() { $this->assertFieldByName($body_key, $edit[$body_key], 'Body field displayed.'); // Edit the content of the block. - $edit = array(); + $edit = []; $edit[$title_key] = $this->randomMachineName(8); $edit[$body_key] = $this->randomMachineName(16); // Stay on the current page, without reloading. @@ -51,21 +51,21 @@ public function testPageEdit() { // Edit the same block, creating a new revision. $this->drupalGet("block/" . $block->id()); - $edit = array(); + $edit = []; $edit['info[0][value]'] = $this->randomMachineName(8); $edit[$body_key] = $this->randomMachineName(16); $edit['revision'] = TRUE; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that the block revision has been created. - \Drupal::entityManager()->getStorage('block_content')->resetCache(array($block->id())); + \Drupal::entityManager()->getStorage('block_content')->resetCache([$block->id()]); $revised_block = BlockContent::load($block->id()); $this->assertNotIdentical($block->getRevisionId(), $revised_block->getRevisionId(), 'A new revision has been created.'); // Test deleting the block. $this->drupalGet("block/" . $revised_block->id()); $this->clickLink(t('Delete')); - $this->assertText(format_string('Are you sure you want to delete the custom block @label?', array('@label' => $revised_block->label()))); + $this->assertText(format_string('Are you sure you want to delete the custom block @label?', ['@label' => $revised_block->label()])); } } diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php index 0bf29fd..7d34373 100644 --- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php +++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentBodyFieldTest.php @@ -15,7 +15,7 @@ */ class MigrateBlockContentBodyFieldTest extends MigrateDrupal7TestBase { - public static $modules = array('block', 'block_content', 'filter', 'text'); + public static $modules = ['block', 'block_content', 'filter', 'text']; /** * {@inheritdoc} diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php index 9a3cbf0..4accc20 100644 --- a/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php +++ b/core/modules/block_content/tests/src/Kernel/Migrate/MigrateBlockContentTypeTest.php @@ -13,7 +13,7 @@ */ class MigrateBlockContentTypeTest extends MigrateDrupal7TestBase { - public static $modules = array('block', 'block_content', 'filter', 'text'); + public static $modules = ['block', 'block_content', 'filter', 'text']; /** * {@inheritdoc} diff --git a/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php b/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php index 42990db..706a7cc 100644 --- a/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php +++ b/core/modules/block_content/tests/src/Kernel/Migrate/d7/MigrateCustomBlockTest.php @@ -13,11 +13,11 @@ */ class MigrateCustomBlockTest extends MigrateDrupal7TestBase { - public static $modules = array( + public static $modules = [ 'block_content', 'filter', 'text', - ); + ]; /** * {@inheritdoc} diff --git a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php index 3ab934c..ced7e84 100644 --- a/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php +++ b/core/modules/block_content/tests/src/Unit/Menu/BlockContentLocalTasksTest.php @@ -13,32 +13,32 @@ class BlockContentLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array( + $this->directoryList = [ 'block' => 'core/modules/block', 'block_content' => 'core/modules/block_content', - ); + ]; parent::setUp(); - $config_factory = $this->getConfigFactoryStub(array('system.theme' => array( + $config_factory = $this->getConfigFactoryStub(['system.theme' => [ 'default' => 'test_c', - ))); + ]]); - $themes = array(); - $themes['test_a'] = (object) array( + $themes = []; + $themes['test_a'] = (object) [ 'status' => 0, - ); - $themes['test_b'] = (object) array( + ]; + $themes['test_b'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_b', - ), - ); - $themes['test_c'] = (object) array( + ], + ]; + $themes['test_c'] = (object) [ 'status' => 1, - 'info' => array( + 'info' => [ 'name' => 'test_c', - ), - ); + ], + ]; $theme_handler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface'); $theme_handler->expects($this->any()) ->method('listInfo') @@ -56,25 +56,25 @@ protected function setUp() { * @dataProvider getBlockContentListingRoutes */ public function testBlockContentListLocalTasks($route) { - $this->assertLocalTasks($route, array( - 0 => array( + $this->assertLocalTasks($route, [ + 0 => [ 'block.admin_display', 'entity.block_content.collection', - ), - 1 => array( + ], + 1 => [ 'block_content.list_sub', 'entity.block_content_type.collection', - ), - )); + ], + ]); } /** * Provides a list of routes to test. */ public function getBlockContentListingRoutes() { - return array( - array('entity.block_content.collection', 'entity.block_content_type.collection'), - ); + return [ + ['entity.block_content.collection', 'entity.block_content_type.collection'], + ]; } } diff --git a/core/modules/book/book.install b/core/modules/book/book.install index 76ddc81..7704483 100644 --- a/core/modules/book/book.install +++ b/core/modules/book/book.install @@ -17,119 +17,119 @@ function book_uninstall() { * Implements hook_schema(). */ function book_schema() { - $schema['book'] = array( + $schema['book'] = [ 'description' => 'Stores book outline information. Uniquely defines the location of each node in the book outline', - 'fields' => array( - 'nid' => array( + 'fields' => [ + 'nid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => "The book page's {node}.nid.", - ), - 'bid' => array( + ], + 'bid' => [ 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, 'description' => "The book ID is the {book}.nid of the top-level page.", - ), - 'pid' => array( + ], + 'pid' => [ 'description' => 'The parent ID (pid) is the id of the node above in the hierarchy, or zero if the node is at the top level in its outline.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'has_children' => array( + ], + 'has_children' => [ 'description' => 'Flag indicating whether any nodes have this node as a parent (1 = children exist, 0 = no children).', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'weight' => array( + ], + 'weight' => [ 'description' => 'Weight among book entries in the same book at the same depth.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, - ), - 'depth' => array( + ], + 'depth' => [ 'description' => 'The depth relative to the top level. A link with pid == 0 will have depth == 1.', 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'size' => 'small', - ), - 'p1' => array( + ], + 'p1' => [ 'description' => 'The first nid in the materialized path. If N = depth, then pN must equal the nid. If depth > 1 then p(N-1) must equal the pid. All pX where X > depth must equal zero. The columns p1 .. p9 are also called the parents.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p2' => array( + ], + 'p2' => [ 'description' => 'The second nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p3' => array( + ], + 'p3' => [ 'description' => 'The third nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p4' => array( + ], + 'p4' => [ 'description' => 'The fourth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p5' => array( + ], + 'p5' => [ 'description' => 'The fifth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p6' => array( + ], + 'p6' => [ 'description' => 'The sixth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p7' => array( + ], + 'p7' => [ 'description' => 'The seventh nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p8' => array( + ], + 'p8' => [ 'description' => 'The eighth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - 'p9' => array( + ], + 'p9' => [ 'description' => 'The ninth nid in the materialized path. See p1.', 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0, - ), - ), - 'primary key' => array('nid'), - 'indexes' => array( - 'book_parents' => array('bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'), - ), - ); + ], + ], + 'primary key' => ['nid'], + 'indexes' => [ + 'book_parents' => ['bid', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9'], + ], + ]; return $schema; } diff --git a/core/modules/book/book.module b/core/modules/book/book.module index ecccb74..988201e 100644 --- a/core/modules/book/book.module +++ b/core/modules/book/book.module @@ -25,17 +25,17 @@ function book_help($route_name, RouteMatchInterface $route_match) { switch ($route_name) { case 'help.page.book': $output = '' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type Book page. For more information, see the online documentation for the Book module.', array(':book' => 'https://www.drupal.org/documentation/modules/book')) . '
'; + $output .= '' . t('The Book module is used for creating structured, multi-page content, such as site resource guides, manuals, and wikis. It allows you to create content that has chapters, sections, subsections, or any similarly-tiered structure. Enabling the module creates a new content type Book page. For more information, see the online documentation for the Book module.', [':book' => 'https://www.drupal.org/documentation/modules/book']) . '
'; $output .= '' . t('The book module offers a means to organize a collection of related content pages, collectively known as a book. When viewed, this content automatically displays links to adjacent book pages, providing a simple navigation system for creating and reviewing structured content.') . '
'; case 'entity.node.book_outline_form': - return '' . t('The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.', array(':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin'))) . '
'; + return '' . t('The outline feature allows you to include pages in the Book hierarchy, as well as move them within the hierarchy or to reorder an entire book.', [':book' => \Drupal::url('book.render'), ':book-admin' => \Drupal::url('book.admin')]) . '
'; } } @@ -55,23 +55,23 @@ function book_help($route_name, RouteMatchInterface $route_match) { * Implements hook_theme(). */ function book_theme() { - return array( - 'book_navigation' => array( - 'variables' => array('book_link' => NULL), - ), - 'book_tree' => array( - 'variables' => array('items' => array(), 'attributes' => array()), - ), - 'book_export_html' => array( - 'variables' => array('title' => NULL, 'contents' => NULL, 'depth' => NULL), - ), - 'book_all_books_block' => array( + return [ + 'book_navigation' => [ + 'variables' => ['book_link' => NULL], + ], + 'book_tree' => [ + 'variables' => ['items' => [], 'attributes' => []], + ], + 'book_export_html' => [ + 'variables' => ['title' => NULL, 'contents' => NULL, 'depth' => NULL], + ], + 'book_all_books_block' => [ 'render element' => 'book_menus', - ), - 'book_node_export_html' => array( - 'variables' => array('node' => NULL, 'content' => NULL, 'children' => NULL), - ), - ); + ], + 'book_node_export_html' => [ + 'variables' => ['node' => NULL, 'content' => NULL, 'children' => NULL], + ], + ]; } /** @@ -97,31 +97,31 @@ function book_node_links_alter(array &$links, NodeInterface $node, array &$conte $child_type = \Drupal::config('book.settings')->get('child_type'); $access_control_handler = \Drupal::entityManager()->getAccessControlHandler('node'); if (($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines')) && $access_control_handler->createAccess($child_type) && $node->isPublished() && $node->book['depth'] < BookManager::BOOK_MAX_DEPTH) { - $book_links['book_add_child'] = array( + $book_links['book_add_child'] = [ 'title' => t('Add child page'), 'url' => Url::fromRoute('node.add', ['node_type' => $child_type], ['query' => ['parent' => $node->id()]]), - ); + ]; } if ($account->hasPermission('access printer-friendly version')) { - $book_links['book_printer'] = array( + $book_links['book_printer'] = [ 'title' => t('Printer-friendly version'), 'url' => Url::fromRoute('book.export', [ 'type' => 'html', 'node' => $node->id(), ]), - 'attributes' => array('title' => t('Show a printer-friendly version of this book page and its sub-pages.')) - ); + 'attributes' => ['title' => t('Show a printer-friendly version of this book page and its sub-pages.')] + ]; } } } if (!empty($book_links)) { - $links['book'] = array( + $links['book'] = [ '#theme' => 'links__node__book', '#links' => $book_links, - '#attributes' => array('class' => array('links', 'inline')), - ); + '#attributes' => ['class' => ['links', 'inline']], + ]; } } } @@ -148,17 +148,17 @@ function book_form_node_form_alter(&$form, FormStateInterface $form_state, $form $collapsed = !($node->isNew() && !empty($node->book['pid'])); $form = \Drupal::service('book.manager')->addFormElements($form, $form_state, $node, $account, $collapsed); // The "js-hide" class hides submit button when Javascript is enabled. - $form['book']['pick-book'] = array( + $form['book']['pick-book'] = [ '#type' => 'submit', '#value' => t('Change book (update list of parents)'), - '#submit' => array('book_pick_book_nojs_submit'), + '#submit' => ['book_pick_book_nojs_submit'], '#weight' => 20, - '#attributes' => array( - 'class' => array( + '#attributes' => [ + 'class' => [ 'js-hide', - ), - ), - ); + ], + ], + ]; $form['#entity_builders'][] = 'book_node_builder'; } } @@ -232,7 +232,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI if (!$book_node->access()) { return; } - $build['book_navigation'] = array( + $build['book_navigation'] = [ '#theme' => 'book_navigation', '#book_link' => $node->book, '#weight' => 100, @@ -241,7 +241,7 @@ function book_node_view(array &$build, EntityInterface $node, EntityViewDisplayI '#cache' => [ 'tags' => $node->getEntityType()->getListCacheTags(), ], - ); + ]; } } } @@ -295,7 +295,7 @@ function book_node_prepare_form(NodeInterface $node, $operation, FormStateInterf // Prepare defaults for the add/edit form. $account = \Drupal::currentUser(); if (empty($node->book) && ($account->hasPermission('add content to books') || $account->hasPermission('administer book outlines'))) { - $node->book = array(); + $node->book = []; $query = \Drupal::request()->query; if ($node->isNew() && !is_null($query->get('parent')) && is_numeric($query->get('parent'))) { @@ -341,10 +341,10 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat } if (isset($node->book) && $node->book['has_children']) { - $form['book_warning'] = array( - '#markup' => '' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', array('%title' => $node->label())) . '
', + $form['book_warning'] = [ + '#markup' => '' . t('%title is part of a book outline, and has associated child pages. If you proceed with deletion, the child pages will be relocated automatically.', ['%title' => $node->label()]) . '
', '#weight' => -10, - ); + ]; } } @@ -365,13 +365,13 @@ function book_form_node_confirm_form_alter(&$form, FormStateInterface $form_stat function template_preprocess_book_all_books_block(&$variables) { // Remove all non-renderable elements. $elements = $variables['book_menus']; - $variables['book_menus'] = array(); + $variables['book_menus'] = []; foreach (Element::children($elements) as $index) { - $variables['book_menus'][] = array( + $variables['book_menus'][] = [ 'id' => $index, 'menu' => $elements[$index], 'title' => $elements[$index]['#book_title'], - ); + ]; } } @@ -391,7 +391,7 @@ function template_preprocess_book_navigation(&$variables) { // Provide extra variables for themers. Not needed by default. $variables['book_id'] = $book_link['bid']; $variables['book_title'] = $book_link['link_title']; - $variables['book_url'] = \Drupal::url('entity.node.canonical', array('node' => $book_link['bid'])); + $variables['book_url'] = \Drupal::url('entity.node.canonical', ['node' => $book_link['bid']]); $variables['current_depth'] = $book_link['depth']; $variables['tree'] = ''; @@ -401,14 +401,14 @@ function template_preprocess_book_navigation(&$variables) { if ($book_link['nid']) { $variables['tree'] = $book_outline->childrenLinks($book_link); - $build = array(); + $build = []; if ($prev = $book_outline->prevLink($book_link)) { - $prev_href = \Drupal::url('entity.node.canonical', array('node' => $prev['nid'])); - $build['#attached']['html_head_link'][][] = array( + $prev_href = \Drupal::url('entity.node.canonical', ['node' => $prev['nid']]); + $build['#attached']['html_head_link'][][] = [ 'rel' => 'prev', 'href' => $prev_href, - ); + ]; $variables['prev_url'] = $prev_href; $variables['prev_title'] = $prev['title']; } @@ -416,21 +416,21 @@ function template_preprocess_book_navigation(&$variables) { /** @var \Drupal\book\BookManagerInterface $book_manager */ $book_manager = \Drupal::service('book.manager'); if ($book_link['pid'] && $parent = $book_manager->loadBookLink($book_link['pid'])) { - $parent_href = \Drupal::url('entity.node.canonical', array('node' => $book_link['pid'])); - $build['#attached']['html_head_link'][][] = array( + $parent_href = \Drupal::url('entity.node.canonical', ['node' => $book_link['pid']]); + $build['#attached']['html_head_link'][][] = [ 'rel' => 'up', 'href' => $parent_href, - ); + ]; $variables['parent_url'] = $parent_href; $variables['parent_title'] = $parent['title']; } if ($next = $book_outline->nextLink($book_link)) { - $next_href = \Drupal::url('entity.node.canonical', array('node' => $next['nid'])); - $build['#attached']['html_head_link'][][] = array( + $next_href = \Drupal::url('entity.node.canonical', ['node' => $next['nid']]); + $build['#attached']['html_head_link'][][] = [ 'rel' => 'next', 'href' => $next_href, - ); + ]; $variables['next_url'] = $next_href; $variables['next_title'] = $next['title']; } @@ -442,7 +442,7 @@ function template_preprocess_book_navigation(&$variables) { $variables['has_links'] = FALSE; // Link variables to filter for values and set state of the flag variable. - $links = array('prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title'); + $links = ['prev_url', 'prev_title', 'parent_url', 'parent_title', 'next_url', 'next_title']; foreach ($links as $link) { if (isset($variables[$link])) { // Flag when there is a value. @@ -475,7 +475,7 @@ function template_preprocess_book_export_html(&$variables) { $variables['language_rtl'] = ($language_interface->getDirection() == LanguageInterface::DIRECTION_RTL); // HTML element attributes. - $attributes = array(); + $attributes = []; $attributes['lang'] = $language_interface->getId(); $attributes['dir'] = $language_interface->getDirection(); $variables['html_attributes'] = new Attribute($attributes); diff --git a/core/modules/book/src/BookBreadcrumbBuilder.php b/core/modules/book/src/BookBreadcrumbBuilder.php index ed39a53..90591d8 100644 --- a/core/modules/book/src/BookBreadcrumbBuilder.php +++ b/core/modules/book/src/BookBreadcrumbBuilder.php @@ -56,10 +56,10 @@ public function applies(RouteMatchInterface $route_match) { * {@inheritdoc} */ public function build(RouteMatchInterface $route_match) { - $book_nids = array(); + $book_nids = []; $breadcrumb = new Breadcrumb(); - $links = array(Link::createFromRoute($this->t('Home'), '' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the online documentation for the Breakpoint module.', array(':docs' => 'https://www.drupal.org/documentation/modules/breakpoint')) . '
'; + $output .= '' . t('The Breakpoint module keeps track of the height, width, and resolution breakpoints where a responsive design needs to change in order to respond to different devices being used to view the site. This module does not have a user interface. For more information, see the online documentation for the Breakpoint module.', [':docs' => 'https://www.drupal.org/documentation/modules/breakpoint']) . '
'; $output .= '' . t('The CKEditor module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the Text Editor module. It requires JavaScript to be enabled in the browser. For more information, see the online documentation for the CKEditor module and the CKEditor website.', array( ':doc_url' => 'https://www.drupal.org/documentation/modules/ckeditor', ':cke_url' => 'http://ckeditor.com', ':text_editor' => \Drupal::url('help.page', array('name' => 'editor')))) . '
'; + $output .= '' . t('The CKEditor module provides a highly-accessible, highly-usable visual text editor and adds a toolbar to text fields. Users can use buttons to format content and to create semantically correct and valid HTML. The CKEditor module uses the framework provided by the Text Editor module. It requires JavaScript to be enabled in the browser. For more information, see the online documentation for the CKEditor module and the CKEditor website.', [ ':doc_url' => 'https://www.drupal.org/documentation/modules/ckeditor', ':cke_url' => 'http://ckeditor.com', ':text_editor' => \Drupal::url('help.page', ['name' => 'editor'])]) . '
'; $output .= ' ' . t('The Color module allows users with the Administer site configuration permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the online documentation for the Color module.', array(':color_do' => 'https://www.drupal.org/documentation/modules/color')) . ' ' . t('The Color module allows users with the Administer site configuration permission to change the color scheme (color of links, backgrounds, text, and other theme elements) of compatible themes. For more information, see the online documentation for the Color module.', [':color_do' => 'https://www.drupal.org/documentation/modules/color']) . ' ' . t('To change the color settings, select the Settings link for your theme on the Appearance page. If the color picker does not appear then the theme is not compatible with the Color module.', array(':appearance' => \Drupal::url('system.themes_page'))) . ' ' . t('To change the color settings, select the Settings link for your theme on the Appearance page. If the color picker does not appear then the theme is not compatible with the Color module.', [':appearance' => \Drupal::url('system.themes_page')]) . ' ' . t('The Color module saves a modified copy of the theme\'s specified stylesheets in the files directory. If you make any manual changes to your theme\'s stylesheet, you must save your color settings again, even if you haven\'t changed the colors. This step is required because the module stylesheets in the files directory need to be recreated to reflect your changes.') . ' ' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the online documentation for the Comment module.', array(':comment' => 'https://www.drupal.org/documentation/modules/comment')) . ' ' . t('The Comment module allows users to comment on site content, set commenting defaults and permissions, and moderate comments. For more information, see the online documentation for the Comment module.', [':comment' => 'https://www.drupal.org/documentation/modules/comment']) . ' ' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', array(
+ $caption .= ' ' . $this->t('%label is used by the %field field on your site. You can not remove this comment type until you have removed the field.', [
'%label' => $this->entity->label(),
'%field' => $field_storage->label(),
- )) . '
',
- )
- ),
- ),
- ));
+ ]
+ ],
+ ],
+ ]);
$filtered_html_format->save();
$editor = Editor::create([
'format' => 'filtered_html',
@@ -72,7 +72,7 @@ function testGetJSSettings() {
$editor = Editor::load('filtered_html');
// Default toolbar.
- $expected_config = $this->getDefaultInternalConfig() + array(
+ $expected_config = $this->getDefaultInternalConfig() + [
'drupalImage_dialogTitleAdd' => 'Insert Image',
'drupalImage_dialogTitleEdit' => 'Edit Image',
'drupalLink_dialogTitleAdd' => 'Add Link',
@@ -84,11 +84,11 @@ function testGetJSSettings() {
'extraPlugins' => 'drupalimage,drupallink',
'language' => 'en',
'stylesSet' => FALSE,
- 'drupalExternalPlugins' => array(
+ 'drupalExternalPlugins' => [
'drupalimage' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupalimage/plugin.js')),
'drupallink' => file_url_transform_relative(file_create_url('core/modules/ckeditor/js/plugins/drupallink/plugin.js')),
- ),
- );
+ ],
+ ];
$expected_config = $this->castSafeStrings($expected_config);
ksort($expected_config);
ksort($expected_config['allowedContent']);
@@ -96,7 +96,7 @@ function testGetJSSettings() {
// Customize the configuration: add button, have two contextually enabled
// buttons, and configure a CKEditor plugin setting.
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$this->container->get('plugin.manager.editor')->clearCachedDefinitions();
$this->ckeditor = $this->container->get('plugin.manager.editor')->createInstance('ckeditor');
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
@@ -121,16 +121,16 @@ function testGetJSSettings() {
$format->filters('filter_html')->settings['allowed_html'] .= '
';
$format->save();
- $expected_config['allowedContent']['pre'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE);
- $expected_config['allowedContent']['h1'] = array('attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE);
- $expected_config['allowedContent']['blockquote'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE);
- $expected_config['allowedContent']['address'] = array('attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*');
+ $expected_config['allowedContent']['pre'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE];
+ $expected_config['allowedContent']['h1'] = ['attributes' => FALSE, 'styles' => FALSE, 'classes' => FALSE];
+ $expected_config['allowedContent']['blockquote'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => TRUE];
+ $expected_config['allowedContent']['address'] = ['attributes' => 'class', 'styles' => FALSE, 'classes' => 'foo,bar-*'];
$expected_config['format_tags'] = 'p;h1;h2;h3;h4;h5;h6;pre';
ksort($expected_config['allowedContent']);
$this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
// Disable the filter_html filter: allow *all *tags.
- $format->setFilterConfig('filter_html', array('status' => 0));
+ $format->setFilterConfig('filter_html', ['status' => 0]);
$format->save();
$expected_config['allowedContent'] = TRUE;
@@ -139,73 +139,73 @@ function testGetJSSettings() {
$this->assertIdentical($expected_config, $this->castSafeStrings($this->ckeditor->getJSSettings($editor)), 'Generated JS settings are correct for customized configuration.');
// Enable the filter_test_restrict_tags_and_attributes filter.
- $format->setFilterConfig('filter_test_restrict_tags_and_attributes', array(
+ $format->setFilterConfig('filter_test_restrict_tags_and_attributes', [
'status' => 1,
- 'settings' => array(
- 'restrictions' => array(
- 'allowed' => array(
+ 'settings' => [
+ 'restrictions' => [
+ 'allowed' => [
'p' => TRUE,
- 'a' => array(
+ 'a' => [
'href' => TRUE,
- 'rel' => array('nofollow' => TRUE),
- 'class' => array('external' => TRUE),
- 'target' => array('_blank' => FALSE),
- ),
- 'span' => array(
- 'class' => array('dodo' => FALSE),
- 'property' => array('dc:*' => TRUE),
- 'rel' => array('foaf:*' => FALSE),
- 'style' => array('underline' => FALSE, 'color' => FALSE, 'font-size' => TRUE),
- ),
- '*' => array(
+ 'rel' => ['nofollow' => TRUE],
+ 'class' => ['external' => TRUE],
+ 'target' => ['_blank' => FALSE],
+ ],
+ 'span' => [
+ 'class' => ['dodo' => FALSE],
+ 'property' => ['dc:*' => TRUE],
+ 'rel' => ['foaf:*' => FALSE],
+ 'style' => ['underline' => FALSE, 'color' => FALSE, 'font-size' => TRUE],
+ ],
+ '*' => [
'style' => FALSE,
'on*' => FALSE,
- 'class' => array('is-a-hipster-llama' => TRUE, 'and-more' => TRUE),
+ 'class' => ['is-a-hipster-llama' => TRUE, 'and-more' => TRUE],
'data-*' => TRUE,
- ),
+ ],
'del' => FALSE,
- ),
- ),
- ),
- ));
+ ],
+ ],
+ ],
+ ]);
$format->save();
- $expected_config['allowedContent'] = array(
- 'p' => array(
+ $expected_config['allowedContent'] = [
+ 'p' => [
'attributes' => TRUE,
'styles' => FALSE,
'classes' => 'is-a-hipster-llama,and-more',
- ),
- 'a' => array(
+ ],
+ 'a' => [
'attributes' => 'href,rel,class,target',
'styles' => FALSE,
'classes' => 'external',
- ),
- 'span' => array(
+ ],
+ 'span' => [
'attributes' => 'class,property,rel,style',
'styles' => 'font-size',
'classes' => FALSE,
- ),
- '*' => array(
+ ],
+ '*' => [
'attributes' => 'class,data-*',
'styles' => FALSE,
'classes' => 'is-a-hipster-llama,and-more',
- ),
- 'del' => array(
+ ],
+ 'del' => [
'attributes' => FALSE,
'styles' => FALSE,
'classes' => FALSE,
- ),
- );
- $expected_config['disallowedContent'] = array(
- 'span' => array(
+ ],
+ ];
+ $expected_config['disallowedContent'] = [
+ 'span' => [
'styles' => 'underline,color',
'classes' => 'dodo',
- ),
- '*' => array(
+ ],
+ '*' => [
'attributes' => 'on*',
- ),
- );
+ ],
+ ];
$expected_config['format_tags'] = 'p';
ksort($expected_config);
ksort($expected_config['allowedContent']);
@@ -232,7 +232,7 @@ function testBuildToolbarJSSetting() {
$this->assertIdentical($expected, $this->castSafeStrings($this->ckeditor->buildToolbarJSSetting($editor)), '"toolbar" configuration part of JS settings built correctly for customized toolbar.');
// Enable the editor_test module, customize further.
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$this->container->get('plugin.manager.ckeditor.plugin')->clearCachedDefinitions();
// Override the label of a toolbar component.
$settings['toolbar']['rows'][0][0]['name'] = 'JunkScience';
@@ -255,7 +255,7 @@ function testBuildContentsCssJSSetting() {
$this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly for default toolbar.');
// Enable the editor_test module, which implements hook_ckeditor_css_alter().
- $this->enableModules(array('ckeditor_test'));
+ $this->enableModules(['ckeditor_test']);
$expected[] = file_url_transform_relative(file_create_url(drupal_get_path('module', 'ckeditor_test') . '/ckeditor_test.css'));
$this->assertIdentical($expected, $this->ckeditor->buildContentsCssJSSetting($editor), '"contentsCss" configuration part of JS settings built correctly while a hook_ckeditor_css_alter() implementation exists.');
@@ -315,7 +315,7 @@ function testStylesComboGetConfig() {
$settings['plugins']['stylescombo']['styles'] = '';
$editor->setSettings($settings);
$editor->save();
- $expected['stylesSet'] = array();
+ $expected['stylesSet'] = [];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Configure the optional "styles" setting in odd ways that shouldn't affect
@@ -333,10 +333,10 @@ function testStylesComboGetConfig() {
$settings['plugins']['stylescombo']['styles'] = "h1.title|Title\np.mAgical.Callout|Callout";
$editor->setSettings($settings);
$editor->save();
- $expected['stylesSet'] = array(
- array('name' => 'Title', 'element' => 'h1', 'attributes' => array('class' => 'title')),
- array('name' => 'Callout', 'element' => 'p', 'attributes' => array('class' => 'mAgical Callout')),
- );
+ $expected['stylesSet'] = [
+ ['name' => 'Title', 'element' => 'h1', 'attributes' => ['class' => 'title']],
+ ['name' => 'Callout', 'element' => 'p', 'attributes' => ['class' => 'mAgical Callout']],
+ ];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Same configuration, but now interspersed with nonsense. Should yield the
@@ -350,7 +350,7 @@ function testStylesComboGetConfig() {
$settings['plugins']['stylescombo']['styles'] = " h1 | Title ";
$editor->setSettings($settings);
$editor->save();
- $expected['stylesSet'] = array(array('name' => 'Title', 'element' => 'h1'));
+ $expected['stylesSet'] = [['name' => 'Title', 'element' => 'h1']];
$this->assertIdentical($expected, $stylescombo_plugin->getConfig($editor), '"StylesCombo" plugin configuration built correctly for customized toolbar.');
// Invalid syntax should cause stylesSet to be set to FALSE.
@@ -366,8 +366,8 @@ function testStylesComboGetConfig() {
*/
function testLanguages() {
// Get CKEditor supported language codes and spot-check.
- $this->enableModules(array('language'));
- $this->installConfig(array('language'));
+ $this->enableModules(['language']);
+ $this->installConfig(['language']);
$langcodes = $this->ckeditor->getLangcodes();
// Language codes transformed with browser mappings.
@@ -390,14 +390,14 @@ function testLanguages() {
* Tests that CKEditor plugins participate in JS translation.
*/
function testJSTranslation() {
- $this->enableModules(array('language', 'locale'));
+ $this->enableModules(['language', 'locale']);
$this->installSchema('locale', 'locales_source');
$this->installSchema('locale', 'locales_location');
$this->installSchema('locale', 'locales_target');
$editor = Editor::load('filtered_html');
$this->ckeditor->getJSSettings($editor);
$localeStorage = $this->container->get('locale.storage');
- $string = $localeStorage->findString(array('source' => 'Edit Link', 'context' => ''));
+ $string = $localeStorage->findString(['source' => 'Edit Link', 'context' => '']);
$this->assertTrue(!empty($string), 'String from JavaScript file saved.');
// With locale module, CKEditor should not adhere to the language selected.
@@ -428,14 +428,14 @@ protected function assertCKEditorLanguage($langcode = 'fr') {
}
protected function getDefaultInternalConfig() {
- return array(
+ return [
'customConfig' => '',
'pasteFromWordPromptCleanup' => TRUE,
'resize_dir' => 'vertical',
- 'justifyClasses' => array('text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'),
+ 'justifyClasses' => ['text-align-left', 'text-align-center', 'text-align-right', 'text-align-justify'],
'entities' => FALSE,
'disableNativeSpellChecker' => FALSE,
- );
+ ];
}
protected function getDefaultAllowedContentConfig() {
@@ -454,42 +454,42 @@ protected function getDefaultAllowedContentConfig() {
}
protected function getDefaultDisallowedContentConfig() {
- return array(
- '*' => array('attributes' => 'on*'),
- );
+ return [
+ '*' => ['attributes' => 'on*'],
+ ];
}
protected function getDefaultToolbarConfig() {
- return array(
- array(
+ return [
+ [
'name' => 'Formatting',
- 'items' => array('Bold', 'Italic',),
- ),
- array(
+ 'items' => ['Bold', 'Italic',],
+ ],
+ [
'name' => 'Links',
- 'items' => array('DrupalLink', 'DrupalUnlink',),
- ),
- array(
+ 'items' => ['DrupalLink', 'DrupalUnlink',],
+ ],
+ [
'name' => 'Lists',
- 'items' => array('BulletedList', 'NumberedList',),
- ),
- array(
+ 'items' => ['BulletedList', 'NumberedList',],
+ ],
+ [
'name' => 'Media',
- 'items' => array('Blockquote', 'DrupalImage',),
- ),
- array(
+ 'items' => ['Blockquote', 'DrupalImage',],
+ ],
+ [
'name' => 'Tools',
- 'items' => array('Source',),
- ),
+ 'items' => ['Source',],
+ ],
'/',
- );
+ ];
}
protected function getDefaultContentsCssConfig() {
- return array(
+ return [
file_url_transform_relative(file_create_url('core/modules/ckeditor/css/ckeditor-iframe.css')),
file_url_transform_relative(file_create_url('core/modules/system/css/components/align.module.css')),
- );
+ ];
}
}
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
index 932b05c..012579d 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/Llama.php
@@ -30,14 +30,14 @@ class Llama extends PluginBase implements CKEditorPluginInterface {
* {@inheritdoc}
*/
function getDependencies(Editor $editor) {
- return array();
+ return [];
}
/**
* {@inheritdoc}
*/
function getLibraries(Editor $editor) {
- return array();
+ return [];
}
/**
@@ -58,7 +58,7 @@ function getFile() {
* {@inheritdoc}
*/
public function getConfig(Editor $editor) {
- return array();
+ return [];
}
}
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
index 7520dfd..4568192 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaButton.php
@@ -18,11 +18,11 @@ class LlamaButton extends Llama implements CKEditorPluginButtonsInterface {
* {@inheritdoc}
*/
function getButtons() {
- return array(
- 'Llama' => array(
+ return [
+ 'Llama' => [
'label' => t('Insert Llama'),
- ),
- );
+ ],
+ ];
}
/**
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
index 43060d9..5e1955f 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaContextualAndButton.php
@@ -39,11 +39,11 @@ function isEnabled(Editor $editor) {
* {@inheritdoc}
*/
function getButtons() {
- return array(
- 'Llama' => array(
+ return [
+ 'Llama' => [
'label' => t('Insert Llama'),
- ),
- );
+ ],
+ ];
}
/**
@@ -58,17 +58,17 @@ function getFile() {
*/
function settingsForm(array $form, FormStateInterface $form_state, Editor $editor) {
// Defaults.
- $config = array('ultra_llama_mode' => FALSE);
+ $config = ['ultra_llama_mode' => FALSE];
$settings = $editor->getSettings();
if (isset($settings['plugins']['llama_contextual_and_button'])) {
$config = $settings['plugins']['llama_contextual_and_button'];
}
- $form['ultra_llama_mode'] = array(
+ $form['ultra_llama_mode'] = [
'#title' => t('Ultra llama mode'),
'#type' => 'checkbox',
'#default_value' => $config['ultra_llama_mode'],
- );
+ ];
return $form;
}
diff --git a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
index 294b39c..d3b9a7f 100644
--- a/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
+++ b/core/modules/ckeditor/tests/modules/src/Plugin/CKEditorPlugin/LlamaCss.php
@@ -20,20 +20,20 @@ class LlamaCss extends Llama implements CKEditorPluginButtonsInterface, CKEditor
* {@inheritdoc}
*/
function getButtons() {
- return array(
- 'LlamaCSS' => array(
+ return [
+ 'LlamaCSS' => [
'label' => t('Insert Llama CSS'),
- ),
- );
+ ],
+ ];
}
/**
* {@inheritdoc}
*/
function getCssFiles(Editor $editor) {
- return array(
+ return [
drupal_get_path('module', 'ckeditor_test') . '/css/llama.css'
- );
+ ];
}
/**
diff --git a/core/modules/color/color.install b/core/modules/color/color.install
index 7f61338..3cc098c 100644
--- a/core/modules/color/color.install
+++ b/core/modules/color/color.install
@@ -9,15 +9,15 @@
* Implements hook_requirements().
*/
function color_requirements($phase) {
- $requirements = array();
+ $requirements = [];
if ($phase == 'runtime') {
// Check for the PHP GD library.
if (function_exists('imagegd2')) {
$info = gd_info();
- $requirements['color_gd'] = array(
+ $requirements['color_gd'] = [
'value' => $info['GD Version'],
- );
+ ];
// Check for PNG support.
if (!function_exists('imagecreatefrompng')) {
@@ -26,11 +26,11 @@ function color_requirements($phase) {
}
}
else {
- $requirements['color_gd'] = array(
+ $requirements['color_gd'] = [
'value' => t('Not installed'),
'severity' => REQUIREMENT_ERROR,
'description' => t('The GD library for PHP is missing or outdated. Check the PHP image documentation for information on how to correct this.'),
- );
+ ];
}
$requirements['color_gd']['title'] = t('GD library PNG support');
}
diff --git a/core/modules/color/color.module b/core/modules/color/color.module
index 3cae045..20d099a 100644
--- a/core/modules/color/color.module
+++ b/core/modules/color/color.module
@@ -23,11 +23,11 @@ function color_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.color':
$output = '
' . t('About') . '
';
- $output .= '' . t('Uses') . '
';
$output .= '';
$output .= '
';
return $output;
@@ -38,11 +38,11 @@ function color_help($route_name, RouteMatchInterface $route_match) {
* Implements hook_theme().
*/
function color_theme() {
- return array(
- 'color_scheme_form' => array(
+ return [
+ 'color_scheme_form' => [
'render element' => 'form',
- ),
- );
+ ],
+ ];
}
/**
@@ -51,14 +51,14 @@ function color_theme() {
function color_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) {
$build_info = $form_state->getBuildInfo();
if (isset($build_info['args'][0]) && ($theme = $build_info['args'][0]) && color_get_info($theme) && function_exists('gd_info')) {
- $form['color'] = array(
+ $form['color'] = [
'#type' => 'details',
'#title' => t('Color scheme'),
'#open' => TRUE,
'#weight' => -1,
- '#attributes' => array('id' => 'color_scheme_form'),
+ '#attributes' => ['id' => 'color_scheme_form'],
'#theme' => 'color_scheme_form',
- );
+ ];
$form['color'] += color_scheme_form($form, $form_state, $theme);
$form['#validate'][] = 'color_scheme_form_validate';
// Ensure color submission happens first so we can unset extra values.
@@ -137,7 +137,7 @@ function color_block_view_pre_render(array $build) {
* Retrieves the Color module information for a particular theme.
*/
function color_get_info($theme) {
- static $theme_info = array();
+ static $theme_info = [];
if (isset($theme_info[$theme])) {
return $theme_info[$theme];
@@ -148,21 +148,21 @@ function color_get_info($theme) {
if ($path && file_exists($file)) {
include $file;
// Add in default values.
- $info += array(
+ $info += [
// CSS files (excluding @import) to rewrite with new color scheme.
- 'css' => array(),
+ 'css' => [],
// Files to copy.
- 'copy' => array(),
+ 'copy' => [],
// Gradient definitions.
- 'gradients' => array(),
+ 'gradients' => [],
// Color areas to fill (x, y, width, height).
- 'fill' => array(),
+ 'fill' => [],
// Coordinates of all the theme slices (x, y, width, height) with their
// filename as used in the stylesheet.
- 'slices' => array(),
+ 'slices' => [],
// Reference color used for blending.
'blend_target' => '#ffffff',
- );
+ ];
$theme_info[$theme] = $info;
return $info;
}
@@ -200,9 +200,9 @@ function color_get_palette($theme, $default = FALSE) {
function color_scheme_form($complete_form, FormStateInterface $form_state, $theme) {
$info = color_get_info($theme);
- $info['schemes'][''] = array('title' => t('Custom'), 'colors' => array());
- $color_sets = array();
- $schemes = array();
+ $info['schemes'][''] = ['title' => t('Custom'), 'colors' => []];
+ $color_sets = [];
+ $schemes = [];
foreach ($info['schemes'] as $key => $scheme) {
$color_sets[$key] = $scheme['title'];
$schemes[$key] = $scheme['colors'];
@@ -233,16 +233,16 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
// Add scheme selector.
$default_palette = color_get_palette($theme, TRUE);
- $form['scheme'] = array(
+ $form['scheme'] = [
'#type' => 'select',
'#title' => t('Color set'),
'#options' => $color_sets,
'#default_value' => $scheme_name,
- '#attached' => array(
- 'library' => array(
+ '#attached' => [
+ 'library' => [
'color/drupal.color',
'color/admin',
- ),
+ ],
// Add custom JavaScript.
'drupalSettings' => [
'color' => [
@@ -251,8 +251,8 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
],
'gradients' => $info['gradients'],
],
- ),
- );
+ ],
+ ];
// Add palette fields. Use the configuration if available.
$palette = $current_scheme ?: $default_palette;
@@ -260,22 +260,22 @@ function color_scheme_form($complete_form, FormStateInterface $form_state, $them
$form['palette']['#tree'] = TRUE;
foreach ($palette as $name => $value) {
if (isset($names[$name])) {
- $form['palette'][$name] = array(
+ $form['palette'][$name] = [
'#type' => 'textfield',
'#title' => $names[$name],
'#value_callback' => 'color_palette_color_value',
'#default_value' => $value,
'#size' => 8,
- '#attributes' => array('dir' => LanguageInterface::DIRECTION_LTR),
- );
+ '#attributes' => ['dir' => LanguageInterface::DIRECTION_LTR],
+ ];
}
}
- $form['theme'] = array('#type' => 'value', '#value' => $theme);
+ $form['theme'] = ['#type' => 'value', '#value' => $theme];
if (isset($info['#attached'])) {
$form['#attached'] = $info['#attached'];
unset($info['#attached']);
}
- $form['info'] = array('#type' => 'value', '#value' => $info);
+ $form['info'] = ['#type' => 'value', '#value' => $info];
return $form;
}
@@ -360,7 +360,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
// Only accept hexadecimal CSS color strings to avoid XSS upon use.
foreach ($form_state->getValue('palette') as $key => $color) {
if (!color_valid_hexadecimal_string($color)) {
- $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', array('%name' => $form['color']['palette'][$key]['#title'])));
+ $form_state->setErrorByName('palette][' . $key, t('You must enter a valid hexadecimal color value for %name.', ['%name' => $form['color']['palette'][$key]['#title']]));
}
}
}
@@ -373,7 +373,7 @@ function color_scheme_form_validate($form, FormStateInterface $form_state) {
function color_scheme_form_submit($form, FormStateInterface $form_state) {
// Avoid color settings spilling over to theme settings.
- $color_settings = array('theme', 'palette', 'scheme');
+ $color_settings = ['theme', 'palette', 'scheme'];
if ($form_state->hasValue('info')) {
$color_settings[] = 'info';
}
@@ -414,7 +414,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$memory_limit = ini_get('memory_limit');
$size = Bytes::toInt($memory_limit);
if (!Environment::checkMemoryLimit($usage + $required, $memory_limit)) {
- drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the PHP documentation for more information.', array('%size' => format_size($usage + $required - $size))), 'error');
+ drupal_set_message(t('There is not enough memory available to PHP to change this theme\'s color scheme. You need at least %size more. Check the PHP documentation for more information.', ['%size' => format_size($usage + $required - $size)]), 'error');
return;
}
}
@@ -446,7 +446,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$paths['target'] = $paths['target'] . '/';
$paths['id'] = $id;
$paths['source'] = drupal_get_path('theme', $theme) . '/';
- $paths['files'] = $paths['map'] = array();
+ $paths['files'] = $paths['map'] = [];
// Save palette and logo location.
$config
@@ -469,10 +469,10 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
}
// Rewrite theme stylesheets.
- $css = array();
+ $css = [];
foreach ($info['css'] as $stylesheet) {
// Build a temporary array with CSS files.
- $files = array();
+ $files = [];
if (file_exists($paths['source'] . $stylesheet)) {
$files[] = $stylesheet;
}
@@ -489,7 +489,7 @@ function color_scheme_form_submit($form, FormStateInterface $form_state) {
$css_optimizer->rewriteFileURIBasePath = base_path() . dirname($paths['source'] . $file) . '/';
// Prefix all paths within this CSS file, ignoring absolute paths.
- $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', array($css_optimizer, 'rewriteFileURI'), $style);
+ $style = preg_replace_callback('/url\([\'"]?(?![a-z]+:|\/+)([^\'")]+)[\'"]?\)/i', [$css_optimizer, 'rewriteFileURI'], $style);
// Rewrite stylesheet with new colors.
$style = _color_rewrite_stylesheet($theme, $info, $paths, $palette, $style);
@@ -729,7 +729,7 @@ function _color_shift($given, $ref1, $ref2, $target) {
* Converts a hex triplet into a GD color.
*/
function _color_gd($img, $hex) {
- $c = array_merge(array($img), _color_unpack($hex));
+ $c = array_merge([$img], _color_unpack($hex));
return call_user_func_array('imagecolorallocate', $c);
}
@@ -739,7 +739,7 @@ function _color_gd($img, $hex) {
function _color_blend($img, $hex1, $hex2, $alpha) {
$in1 = _color_unpack($hex1);
$in2 = _color_unpack($hex2);
- $out = array($img);
+ $out = [$img];
for ($i = 0; $i < 3; ++$i) {
$out[] = $in1[$i] + ($in2[$i] - $in1[$i]) * $alpha;
}
@@ -784,11 +784,11 @@ function _color_hsl2rgb($hsl) {
$m2 = ($l <= 0.5) ? $l * ($s + 1) : $l + $s - $l * $s;
$m1 = $l * 2 - $m2;
- return array(
+ return [
_color_hue2rgb($m1, $m2, $h + 0.33333),
_color_hue2rgb($m1, $m2, $h),
_color_hue2rgb($m1, $m2, $h - 0.33333),
- );
+ ];
}
/**
@@ -828,5 +828,5 @@ function _color_rgb2hsl($rgb) {
$h /= 6;
}
- return array($h, $s, $l);
+ return [$h, $s, $l];
}
diff --git a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
index b88e8ea..ee77a5a 100644
--- a/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
+++ b/core/modules/color/tests/modules/color_test/themes/color_test_theme/color/color.inc
@@ -5,29 +5,29 @@
* Lists available colors and color schemes for the Color test theme.
*/
-$info = array(
- 'fields' => array(
+$info = [
+ 'fields' => [
'bg' => t('Main background'),
'text' => t('Text color'),
- ),
- 'schemes' => array(
- 'default' => array(
+ ],
+ 'schemes' => [
+ 'default' => [
'title' => t('Default'),
- 'colors' => array(
+ 'colors' => [
'bg' => '#ff0000',
'text' => '#0000ff',
- ),
- ),
- 'custom' => array(
+ ],
+ ],
+ 'custom' => [
'title' => t('Custom'),
- 'colors' => array(
+ 'colors' => [
'bg' => '#ff0000',
'text' => '#3b3b3b',
- ),
- ),
- ),
- 'css' => array(
+ ],
+ ],
+ ],
+ 'css' => [
'css/colors.css',
- ),
+ ],
'preview_html' => 'color/preview.html',
-);
+];
diff --git a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
index 157deb8..e55275d 100644
--- a/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
+++ b/core/modules/color/tests/src/Functional/ColorConfigSchemaTest.php
@@ -16,7 +16,7 @@ class ColorConfigSchemaTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('color');
+ public static $modules = ['color'];
/**
* A user with administrative permissions.
@@ -30,10 +30,10 @@ class ColorConfigSchemaTest extends BrowserTestBase {
*/
protected function setUp() {
parent::setUp();
- \Drupal::service('theme_handler')->install(array('bartik'));
+ \Drupal::service('theme_handler')->install(['bartik']);
// Create user.
- $this->adminUser = $this->drupalCreateUser(array('administer themes'));
+ $this->adminUser = $this->drupalCreateUser(['administer themes']);
$this->drupalLogin($this->adminUser);
}
diff --git a/core/modules/color/tests/src/Functional/ColorTest.php b/core/modules/color/tests/src/Functional/ColorTest.php
index dc44566..8416913 100644
--- a/core/modules/color/tests/src/Functional/ColorTest.php
+++ b/core/modules/color/tests/src/Functional/ColorTest.php
@@ -17,7 +17,7 @@ class ColorTest extends BrowserTestBase {
*
* @var array
*/
- public static $modules = array('color', 'color_test', 'block', 'file');
+ public static $modules = ['color', 'color_test', 'block', 'file'];
/**
* A user with administrative permissions.
@@ -50,25 +50,25 @@ protected function setUp() {
parent::setUp();
// Create user.
- $this->bigUser = $this->drupalCreateUser(array('administer themes'));
+ $this->bigUser = $this->drupalCreateUser(['administer themes']);
// This tests the color module in Bartik.
- $this->themes = array(
- 'bartik' => array(
+ $this->themes = [
+ 'bartik' => [
'palette_input' => 'palette[bg]',
'scheme' => 'slate',
'scheme_color' => '#3b3b3b',
- ),
- 'color_test_theme' => array(
+ ],
+ 'color_test_theme' => [
'palette_input' => 'palette[bg]',
'scheme' => 'custom',
'scheme_color' => '#3b3b3b',
- ),
- );
+ ],
+ ];
\Drupal::service('theme_handler')->install(array_keys($this->themes));
// Array filled with valid and not valid color values.
- $this->colorTests = array(
+ $this->colorTests = [
'#000' => TRUE,
'#123456' => TRUE,
'#abcdef' => TRUE,
@@ -78,7 +78,7 @@ protected function setUp() {
'#00000' => FALSE,
'123456' => FALSE,
'#00000g' => FALSE,
- );
+ ];
}
/**
@@ -138,7 +138,7 @@ function _testColor($theme, $test_values) {
$config->set('css.preprocess', 1);
$config->save();
$this->drupalGet('' . t('About') . '
';
- $output .= '' . t('Uses') . '
';
$output .= '';
$output .= '
';
return $output;
@@ -96,10 +96,10 @@ function comment_help($route_name, RouteMatchInterface $route_match) {
function comment_uri(CommentInterface $comment) {
return new Url(
'entity.comment.canonical',
- array(
+ [
'comment' => $comment->id(),
- ),
- array('fragment' => 'comment-' . $comment->id())
+ ],
+ ['fragment' => 'comment-' . $comment->id()]
);
}
@@ -107,23 +107,23 @@ function comment_uri(CommentInterface $comment) {
* Implements hook_entity_extra_field_info().
*/
function comment_entity_extra_field_info() {
- $return = array();
+ $return = [];
foreach (CommentType::loadMultiple() as $comment_type) {
- $return['comment'][$comment_type->id()] = array(
- 'form' => array(
- 'author' => array(
+ $return['comment'][$comment_type->id()] = [
+ 'form' => [
+ 'author' => [
'label' => t('Author'),
'description' => t('Author textfield'),
'weight' => -2,
- ),
- ),
- );
- $return['comment'][$comment_type->id()]['display']['links'] = array(
+ ],
+ ],
+ ];
+ $return['comment'][$comment_type->id()]['display']['links'] = [
'label' => t('Links'),
'description' => t('Comment operation links'),
'weight' => 100,
'visible' => TRUE,
- );
+ ];
}
return $return;
@@ -133,14 +133,14 @@ function comment_entity_extra_field_info() {
* Implements hook_theme().
*/
function comment_theme() {
- return array(
- 'comment' => array(
+ return [
+ 'comment' => [
'render element' => 'elements',
- ),
- 'field__comment' => array(
+ ],
+ 'field__comment' => [
'base hook' => 'field',
- ),
- );
+ ],
+ ];
}
/**
@@ -150,15 +150,15 @@ function comment_field_config_create(FieldConfigInterface $field) {
if ($field->getType() == 'comment' && !$field->isSyncing()) {
// Assign default values for the field.
$default_value = $field->getDefaultValueLiteral();
- $default_value += array(array());
- $default_value[0] += array(
+ $default_value += [[]];
+ $default_value[0] += [
'status' => CommentItemInterface::OPEN,
'cid' => 0,
'last_comment_timestamp' => 0,
'last_comment_name' => '',
'last_comment_uid' => 0,
'comment_count' => 0,
- );
+ ];
$field->setDefaultValue($default_value);
}
}
@@ -227,14 +227,14 @@ function comment_entity_view(array &$build, EntityInterface $entity, EntityViewD
if ($entity->hasField($field_name) && $entity->get($field_name)->status != CommentItemInterface::HIDDEN) {
// Add a comments RSS element which is a URL to the comments of this
// entity.
- $options = array(
+ $options = [
'fragment' => 'comments',
'absolute' => TRUE,
- );
- $entity->rss_elements[] = array(
+ ];
+ $entity->rss_elements[] = [
'key' => 'comments',
'value' => $entity->url('canonical', $options),
- );
+ ];
}
}
}
@@ -457,7 +457,7 @@ function comment_node_update_index(EntityInterface $node) {
}
}
- $build = array();
+ $build = [];
if ($index_comments) {
foreach (\Drupal::service('comment.manager')->getFields('node') as $field_name => $info) {
@@ -517,7 +517,7 @@ function comment_node_search_result(EntityInterface $node) {
// Do not make a string if there are no comment fields, or no comments exist
// or all comment fields are hidden.
if ($comments > 0 || $open) {
- return array('comment' => \Drupal::translation()->formatPlural($comments, '1 comment', '@count comments'));
+ return ['comment' => \Drupal::translation()->formatPlural($comments, '1 comment', '@count comments')];
}
}
@@ -527,7 +527,7 @@ function comment_node_search_result(EntityInterface $node) {
function comment_user_cancel($edit, $account, $method) {
switch ($method) {
case 'user_cancel_block_unpublish':
- $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
+ $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) {
$comment->setPublished(CommentInterface::NOT_PUBLISHED);
$comment->save();
@@ -536,7 +536,7 @@ function comment_user_cancel($edit, $account, $method) {
case 'user_cancel_reassign':
/** @var \Drupal\comment\CommentInterface[] $comments */
- $comments = entity_load_multiple_by_properties('comment', array('uid' => $account->id()));
+ $comments = entity_load_multiple_by_properties('comment', ['uid' => $account->id()]);
foreach ($comments as $comment) {
$comment->setOwnerId(0);
$comment->setAuthorName(\Drupal::config('user.settings')->get('anonymous'));
@@ -568,7 +568,7 @@ function comment_user_predelete($account) {
* An array as expected by drupal_render().
*/
function comment_preview(CommentInterface $comment, FormStateInterface $form_state) {
- $preview_build = array();
+ $preview_build = [];
$entity = $comment->getCommentedEntity();
if (!$form_state->getErrors()) {
@@ -580,7 +580,7 @@ function comment_preview(CommentInterface $comment, FormStateInterface $form_sta
}
if ($comment->hasParentComment()) {
- $build = array();
+ $build = [];
$parent = $comment->getParentComment();
if ($parent && $parent->isPublished()) {
$build = \Drupal::entityTypeManager()->getViewBuilder('comment')->view($parent);
@@ -636,10 +636,10 @@ function template_preprocess_comment(&$variables) {
$variables['threaded'] = $variables['elements']['#comment_threaded'];
$account = $comment->getOwner();
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $account,
- );
+ ];
$variables['author'] = drupal_render($username);
$variables['author_id'] = $comment->getOwnerId();
$variables['new_indicator_timestamp'] = $comment->getChangedTime();
@@ -658,7 +658,7 @@ function template_preprocess_comment(&$variables) {
$variables['user_picture'] = user_view($account, 'compact');
}
else {
- $variables['user_picture'] = array();
+ $variables['user_picture'] = [];
}
if (isset($comment->in_preview)) {
@@ -667,25 +667,25 @@ function template_preprocess_comment(&$variables) {
}
else {
$uri = $comment->permalink();
- $attributes = $uri->getOption('attributes') ?: array();
- $attributes += array('class' => array('permalink'), 'rel' => 'bookmark');
+ $attributes = $uri->getOption('attributes') ?: [];
+ $attributes += ['class' => ['permalink'], 'rel' => 'bookmark'];
$uri->setOption('attributes', $attributes);
$variables['title'] = \Drupal::l($comment->getSubject(), $uri);
$variables['permalink'] = \Drupal::l(t('Permalink'), $comment->permalink());
}
- $variables['submitted'] = t('Submitted by @username on @datetime', array('@username' => $variables['author'], '@datetime' => $variables['created']));
+ $variables['submitted'] = t('Submitted by @username on @datetime', ['@username' => $variables['author'], '@datetime' => $variables['created']]);
if ($comment->hasParentComment()) {
// Fetch and store the parent comment information for use in templates.
$comment_parent = $comment->getParentComment();
$account_parent = $comment_parent->getOwner();
$variables['parent_comment'] = $comment_parent;
- $username = array(
+ $username = [
'#theme' => 'username',
'#account' => $account_parent,
- );
+ ];
$variables['parent_author'] = drupal_render($username);
$variables['parent_created'] = format_date($comment_parent->getCreatedTime());
// Avoid calling format_date() twice on the same timestamp.
@@ -696,13 +696,13 @@ function template_preprocess_comment(&$variables) {
$variables['parent_changed'] = format_date($comment_parent->getChangedTime());
}
$permalink_uri_parent = $comment_parent->permalink();
- $attributes = $permalink_uri_parent->getOption('attributes') ?: array();
- $attributes += array('class' => array('permalink'), 'rel' => 'bookmark');
+ $attributes = $permalink_uri_parent->getOption('attributes') ?: [];
+ $attributes += ['class' => ['permalink'], 'rel' => 'bookmark'];
$permalink_uri_parent->setOption('attributes', $attributes);
$variables['parent_title'] = \Drupal::l($comment_parent->getSubject(), $permalink_uri_parent);
$variables['parent_permalink'] = \Drupal::l(t('Parent permalink'), $permalink_uri_parent);
$variables['parent'] = t('In reply to @parent_title by @parent_username',
- array('@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title']));
+ ['@parent_username' => $variables['parent_author'], '@parent_title' => $variables['parent_title']]);
}
else {
$variables['parent_comment'] = '';
diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc
index 5af2e6a..8841441 100644
--- a/core/modules/comment/comment.tokens.inc
+++ b/core/modules/comment/comment.tokens.inc
@@ -15,11 +15,11 @@
* Implements hook_token_info().
*/
function comment_token_info() {
- $type = array(
+ $type = [
'name' => t('Comments'),
'description' => t('Tokens for comments posted on the site.'),
'needs-data' => 'comment',
- );
+ ];
$tokens = [];
// Provide a integration for each entity type except comment.
@@ -45,76 +45,76 @@ function comment_token_info() {
}
// Core comment tokens
- $comment['cid'] = array(
+ $comment['cid'] = [
'name' => t("Comment ID"),
'description' => t("The unique ID of the comment."),
- );
- $comment['hostname'] = array(
+ ];
+ $comment['hostname'] = [
'name' => t("IP Address"),
'description' => t("The IP address of the computer the comment was posted from."),
- );
- $comment['mail'] = array(
+ ];
+ $comment['mail'] = [
'name' => t("Email address"),
'description' => t("The email address left by the comment author."),
- );
- $comment['homepage'] = array(
+ ];
+ $comment['homepage'] = [
'name' => t("Home page"),
'description' => t("The home page URL left by the comment author."),
- );
- $comment['title'] = array(
+ ];
+ $comment['title'] = [
'name' => t("Title"),
'description' => t("The title of the comment."),
- );
- $comment['body'] = array(
+ ];
+ $comment['body'] = [
'name' => t("Content"),
'description' => t("The formatted content of the comment itself."),
- );
- $comment['langcode'] = array(
+ ];
+ $comment['langcode'] = [
'name' => t('Language code'),
'description' => t('The language code of the language the comment is written in.'),
- );
- $comment['url'] = array(
+ ];
+ $comment['url'] = [
'name' => t("URL"),
'description' => t("The URL of the comment."),
- );
- $comment['edit-url'] = array(
+ ];
+ $comment['edit-url'] = [
'name' => t("Edit URL"),
'description' => t("The URL of the comment's edit page."),
- );
+ ];
// Chained tokens for comments
- $comment['created'] = array(
+ $comment['created'] = [
'name' => t("Date created"),
'description' => t("The date the comment was posted."),
'type' => 'date',
- );
- $comment['changed'] = array(
+ ];
+ $comment['changed'] = [
'name' => t("Date changed"),
'description' => t("The date the comment was most recently updated."),
'type' => 'date',
- );
- $comment['parent'] = array(
+ ];
+ $comment['parent'] = [
'name' => t("Parent"),
'description' => t("The comment's parent, if comment threading is active."),
'type' => 'comment',
- );
- $comment['entity'] = array(
+ ];
+ $comment['entity'] = [
'name' => t("Entity"),
'description' => t("The entity the comment was posted to."),
'type' => 'entity',
- );
- $comment['author'] = array(
+ ];
+ $comment['author'] = [
'name' => t("Author"),
'description' => t("The author name of the comment."),
'type' => 'user',
- );
+ ];
- return array(
- 'types' => array('comment' => $type),
- 'tokens' => array(
+ return [
+ 'types' => ['comment' => $type],
+ 'tokens' => [
'comment' => $comment,
- ) + $tokens,
- );
+ ] + $tokens,
+ ];
}
/**
@@ -123,7 +123,7 @@ function comment_token_info() {
function comment_tokens($type, $tokens, array $data, array $options, BubbleableMetadata $bubbleable_metadata) {
$token_service = \Drupal::token();
- $url_options = array('absolute' => TRUE);
+ $url_options = ['absolute' => TRUE];
if (isset($options['langcode'])) {
$url_options['language'] = \Drupal::languageManager()->getLanguage($options['langcode']);
$langcode = $options['langcode'];
@@ -131,7 +131,7 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
else {
$langcode = NULL;
}
- $replacements = array();
+ $replacements = [];
if ($type == 'comment' && !empty($data['comment'])) {
/** @var \Drupal\comment\CommentInterface $comment */
@@ -230,23 +230,23 @@ function comment_tokens($type, $tokens, array $data, array $options, BubbleableM
// Chained token relationships.
if ($entity_tokens = $token_service->findwithPrefix($tokens, 'entity')) {
$entity = $comment->getCommentedEntity();
- $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, array($comment->getCommentedEntityTypeId() => $entity), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate($comment->getCommentedEntityTypeId(), $entity_tokens, [$comment->getCommentedEntityTypeId() => $entity], $options, $bubbleable_metadata);
}
if ($date_tokens = $token_service->findwithPrefix($tokens, 'created')) {
- $replacements += $token_service->generate('date', $date_tokens, array('date' => $comment->getCreatedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $date_tokens, ['date' => $comment->getCreatedTime()], $options, $bubbleable_metadata);
}
if ($date_tokens = $token_service->findwithPrefix($tokens, 'changed')) {
- $replacements += $token_service->generate('date', $date_tokens, array('date' => $comment->getChangedTime()), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('date', $date_tokens, ['date' => $comment->getChangedTime()], $options, $bubbleable_metadata);
}
if (($parent_tokens = $token_service->findwithPrefix($tokens, 'parent')) && $parent = $comment->getParentComment()) {
- $replacements += $token_service->generate('comment', $parent_tokens, array('comment' => $parent), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('comment', $parent_tokens, ['comment' => $parent], $options, $bubbleable_metadata);
}
if (($author_tokens = $token_service->findwithPrefix($tokens, 'author')) && $account = $comment->getOwner()) {
- $replacements += $token_service->generate('user', $author_tokens, array('user' => $account), $options, $bubbleable_metadata);
+ $replacements += $token_service->generate('user', $author_tokens, ['user' => $account], $options, $bubbleable_metadata);
}
}
// Replacement tokens for any content entities that have comment field.
diff --git a/core/modules/comment/comment.views.inc b/core/modules/comment/comment.views.inc
index fb11a4f..11abede 100644
--- a/core/modules/comment/comment.views.inc
+++ b/core/modules/comment/comment.views.inc
@@ -13,14 +13,14 @@
function comment_views_data_alter(&$data) {
// New comments are only supported for node table because it requires the
// history table.
- $data['node']['new_comments'] = array(
+ $data['node']['new_comments'] = [
'title' => t('New comments'),
'help' => t('The number of new comments on the node.'),
- 'field' => array(
+ 'field' => [
'id' => 'node_new_comments',
'no group by' => TRUE,
- ),
- );
+ ],
+ ];
// Provide a integration for each entity type except comment.
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
@@ -29,25 +29,25 @@ function comment_views_data_alter(&$data) {
}
$fields = \Drupal::service('comment.manager')->getFields($entity_type_id);
$base_table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
- $args = array('@entity_type' => $entity_type_id);
+ $args = ['@entity_type' => $entity_type_id];
if ($fields) {
- $data[$base_table]['comments_link'] = array(
- 'field' => array(
+ $data[$base_table]['comments_link'] = [
+ 'field' => [
'title' => t('Add comment link'),
'help' => t('Display the standard add comment link used on regular @entity_type, which will only display if the viewing user has access to add a comment.', $args),
'id' => 'comment_entity_link',
- ),
- );
+ ],
+ ];
// Multilingual properties are stored in data table.
if (!($table = $entity_type->getDataTable())) {
$table = $entity_type->getBaseTable();
}
- $data[$table]['uid_touch'] = array(
+ $data[$table]['uid_touch'] = [
'title' => t('User posted or commented'),
'help' => t('Display nodes only if a user posted the @entity_type or commented on the @entity_type.', $args),
- 'argument' => array(
+ 'argument' => [
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
@@ -55,40 +55,40 @@ function comment_views_data_alter(&$data) {
'no group by' => TRUE,
'entity_type' => $entity_type_id,
'entity_id' => $entity_type->getKey('id'),
- ),
- 'filter' => array(
+ ],
+ 'filter' => [
'field' => 'uid',
'name table' => 'users_field_data',
'name field' => 'name',
'id' => 'comment_user_uid',
'entity_type' => $entity_type_id,
'entity_id' => $entity_type->getKey('id'),
- ),
- );
+ ],
+ ];
foreach ($fields as $field_name => $field) {
- $data[$base_table][$field_name . '_cid'] = array(
- 'title' => t('Comments of the @entity_type using field: @field_name', $args + array('@field_name' => $field_name)),
+ $data[$base_table][$field_name . '_cid'] = [
+ 'title' => t('Comments of the @entity_type using field: @field_name', $args + ['@field_name' => $field_name]),
'help' => t('Relate all comments on the @entity_type. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.', $args),
- 'relationship' => array(
+ 'relationship' => [
'group' => t('Comment'),
'label' => t('Comments'),
'base' => 'comment_field_data',
'base field' => 'entity_id',
'relationship field' => $entity_type->getKey('id'),
'id' => 'standard',
- 'extra' => array(
- array(
+ 'extra' => [
+ [
'field' => 'entity_type',
'value' => $entity_type_id,
- ),
- array(
+ ],
+ [
'field' => 'field_name',
'value' => $field_name,
- ),
- ),
- ),
- );
+ ],
+ ],
+ ],
+ ];
}
}
}
diff --git a/core/modules/comment/src/CommentAccessControlHandler.php b/core/modules/comment/src/CommentAccessControlHandler.php
index 639575a..bcb0fd7 100644
--- a/core/modules/comment/src/CommentAccessControlHandler.php
+++ b/core/modules/comment/src/CommentAccessControlHandler.php
@@ -67,23 +67,23 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_
if ($operation == 'edit') {
// Only users with the "administer comments" permission can edit
// administrative fields.
- $administrative_fields = array(
+ $administrative_fields = [
'uid',
'status',
'created',
'date',
- );
+ ];
if (in_array($field_definition->getName(), $administrative_fields, TRUE)) {
return AccessResult::allowedIfHasPermission($account, 'administer comments');
}
// No user can change read-only fields.
- $read_only_fields = array(
+ $read_only_fields = [
'hostname',
'changed',
'cid',
'thread',
- );
+ ];
// These fields can be edited during comment creation.
$create_only_fields = [
'comment_type',
diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php
index 3a2e704..28231b8 100644
--- a/core/modules/comment/src/CommentForm.php
+++ b/core/modules/comment/src/CommentForm.php
@@ -91,7 +91,7 @@ public function form(array $form, FormStateInterface $form_state) {
// Use #comment-form as unique jump target, regardless of entity type.
$form['#id'] = Html::getUniqueId('comment_form');
- $form['#theme'] = array('comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form');
+ $form['#theme'] = ['comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form'];
$anonymous_contact = $field_definition->getSetting('anonymous');
$is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments');
@@ -104,7 +104,7 @@ public function form(array $form, FormStateInterface $form_state) {
// If not replying to a comment, use our dedicated page callback for new
// Comments on entities.
if (!$comment->id() && !$comment->hasParentComment()) {
- $form['#action'] = $this->url('comment.reply', array('entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name));
+ $form['#action'] = $this->url('comment.reply', ['entity_type' => $entity->getEntityTypeId(), 'entity' => $entity->id(), 'field_name' => $field_name]);
}
$comment_preview = $form_state->get('comment_preview');
@@ -112,13 +112,13 @@ public function form(array $form, FormStateInterface $form_state) {
$form += $comment_preview;
}
- $form['author'] = array();
+ $form['author'] = [];
// Display author information in a details element for comment moderators.
if ($is_admin) {
- $form['author'] += array(
+ $form['author'] += [
'#type' => 'details',
'#title' => $this->t('Administration'),
- );
+ ];
}
// Prepare default values for form elements.
@@ -129,9 +129,9 @@ public function form(array $form, FormStateInterface $form_state) {
}
$status = $comment->getStatus();
if (empty($comment_preview)) {
- $form['#title'] = $this->t('Edit comment %title', array(
+ $form['#title'] = $this->t('Edit comment %title', [
'%title' => $comment->getSubject(),
- ));
+ ]);
}
}
else {
@@ -162,7 +162,7 @@ public function form(array $form, FormStateInterface $form_state) {
// The name field is displayed when an anonymous user is adding a comment or
// when a user with the permission 'administer comments' is editing an
// existing comment from an anonymous user.
- $form['author']['name'] = array(
+ $form['author']['name'] = [
'#type' => 'textfield',
'#title' => $is_admin ? $this->t('Name for @anonymous', ['@anonymous' => $config->get('anonymous')]) : $this->t('Your name'),
'#default_value' => $author,
@@ -173,20 +173,20 @@ public function form(array $form, FormStateInterface $form_state) {
'#attributes' => [
'data-drupal-default-value' => $config->get('anonymous'),
],
- );
+ ];
if ($is_admin) {
// When editing a comment only display the name textfield if the uid field
// is empty.
$form['author']['name']['#states'] = [
'visible' => [
- ':input[name="uid"]' => array('empty' => TRUE),
+ ':input[name="uid"]' => ['empty' => TRUE],
],
];
}
// Add author email and homepage fields depending on the current user.
- $form['author']['mail'] = array(
+ $form['author']['mail'] = [
'#type' => 'email',
'#title' => $this->t('Email'),
'#default_value' => $comment->getAuthorEmail(),
@@ -195,36 +195,36 @@ public function form(array $form, FormStateInterface $form_state) {
'#size' => 30,
'#description' => $this->t('The content of this field is kept private and will not be shown publicly.'),
'#access' => ($comment->getOwner()->isAnonymous() && $is_admin) || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
- );
+ ];
- $form['author']['homepage'] = array(
+ $form['author']['homepage'] = [
'#type' => 'url',
'#title' => $this->t('Homepage'),
'#default_value' => $comment->getHomepage(),
'#maxlength' => 255,
'#size' => 30,
'#access' => $is_admin || ($this->currentUser->isAnonymous() && $anonymous_contact != COMMENT_ANONYMOUS_MAYNOT_CONTACT),
- );
+ ];
// Add administrative comment publishing options.
- $form['author']['date'] = array(
+ $form['author']['date'] = [
'#type' => 'datetime',
'#title' => $this->t('Authored on'),
'#default_value' => $date,
'#size' => 20,
'#access' => $is_admin,
- );
+ ];
- $form['author']['status'] = array(
+ $form['author']['status'] = [
'#type' => 'radios',
'#title' => $this->t('Status'),
'#default_value' => $status,
- '#options' => array(
+ '#options' => [
CommentInterface::PUBLISHED => $this->t('Published'),
CommentInterface::NOT_PUBLISHED => $this->t('Not published'),
- ),
+ ],
'#access' => $is_admin,
- );
+ ];
return parent::form($form, $form_state, $comment);
}
@@ -250,12 +250,12 @@ protected function actions(array $form, FormStateInterface $form_state) {
// already previewing the submission.
$element['submit']['#access'] = ($comment->id() && $this->currentUser->hasPermission('administer comments')) || $preview_mode != DRUPAL_REQUIRED || $form_state->get('comment_preview');
- $element['preview'] = array(
+ $element['preview'] = [
'#type' => 'submit',
'#value' => $this->t('Preview'),
'#access' => $preview_mode != DRUPAL_DISABLED,
- '#submit' => array('::submitForm', '::preview'),
- );
+ '#submit' => ['::submitForm', '::preview'],
+ ];
return $element;
}
@@ -365,10 +365,10 @@ public function save(array $form, FormStateInterface $form_state) {
$form_state->setValue('cid', $comment->id());
// Add a log entry.
- $logger->notice('Comment posted: %subject.', array(
+ $logger->notice('Comment posted: %subject.', [
'%subject' => $comment->getSubject(),
'link' => $this->l(t('View'), $comment->urlInfo()->setOption('fragment', 'comment-' . $comment->id()))
- ));
+ ]);
// Explain the approval queue if necessary.
if (!$comment->isPublished()) {
@@ -379,7 +379,7 @@ public function save(array $form, FormStateInterface $form_state) {
else {
drupal_set_message($this->t('Your comment has been posted.'));
}
- $query = array();
+ $query = [];
// Find the current display page for this comment.
$field_definition = $this->entityManager->getFieldDefinitions($entity->getEntityTypeId(), $entity->bundle())[$field_name];
$page = $this->entityManager->getStorage('comment')->getDisplayOrdinal($comment, $field_definition->getSetting('default_mode'), $field_definition->getSetting('per_page'));
@@ -391,8 +391,8 @@ public function save(array $form, FormStateInterface $form_state) {
$uri->setOption('fragment', 'comment-' . $comment->id());
}
else {
- $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject()));
- drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->getSubject())), 'error');
+ $logger->warning('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]);
+ drupal_set_message($this->t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', ['%subject' => $comment->getSubject()]), 'error');
// Redirect the user to the entity they are commenting on.
}
$form_state->setRedirectUrl($uri);
diff --git a/core/modules/comment/src/CommentLazyBuilders.php b/core/modules/comment/src/CommentLazyBuilders.php
index 4eeeb59..730c840 100644
--- a/core/modules/comment/src/CommentLazyBuilders.php
+++ b/core/modules/comment/src/CommentLazyBuilders.php
@@ -99,13 +99,13 @@ public function __construct(EntityManagerInterface $entity_manager, EntityFormBu
* A renderable array containing the comment form.
*/
public function renderForm($commented_entity_type_id, $commented_entity_id, $field_name, $comment_type_id) {
- $values = array(
+ $values = [
'entity_type' => $commented_entity_type_id,
'entity_id' => $commented_entity_id,
'field_name' => $field_name,
'comment_type' => $comment_type_id,
'pid' => NULL,
- );
+ ];
$comment = $this->entityManager->getStorage('comment')->create($values);
return $this->entityFormBuilder->getForm($comment);
}
@@ -126,11 +126,11 @@ public function renderForm($commented_entity_type_id, $commented_entity_id, $fie
* A renderable array representing the comment links.
*/
public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_preview) {
- $links = array(
+ $links = [
'#theme' => 'links__comment',
- '#pre_render' => array('drupal_pre_render_links'),
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#pre_render' => ['drupal_pre_render_links'],
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
if (!$is_in_preview) {
/** @var \Drupal\comment\CommentInterface $entity */
@@ -140,11 +140,11 @@ public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_pr
$links['comment'] = $this->buildLinks($entity, $commented_entity);
// Allow other modules to alter the comment links.
- $hook_context = array(
+ $hook_context = [
'view_mode' => $view_mode,
'langcode' => $langcode,
'commented_entity' => $commented_entity,
- );
+ ];
$this->moduleHandler->alter('comment_links', $links, $entity, $hook_context);
}
return $links;
@@ -162,25 +162,25 @@ public function renderLinks($comment_entity_id, $view_mode, $langcode, $is_in_pr
* An array that can be processed by drupal_pre_render_links().
*/
protected function buildLinks(CommentInterface $entity, EntityInterface $commented_entity) {
- $links = array();
+ $links = [];
$status = $commented_entity->get($entity->getFieldName())->status;
if ($status == CommentItemInterface::OPEN) {
if ($entity->access('delete')) {
- $links['comment-delete'] = array(
+ $links['comment-delete'] = [
'title' => t('Delete'),
'url' => $entity->urlInfo('delete-form'),
- );
+ ];
}
if ($entity->access('update')) {
- $links['comment-edit'] = array(
+ $links['comment-edit'] = [
'title' => t('Edit'),
'url' => $entity->urlInfo('edit-form'),
- );
+ ];
}
if ($entity->access('create')) {
- $links['comment-reply'] = array(
+ $links['comment-reply'] = [
'title' => t('Reply'),
'url' => Url::fromRoute('comment.reply', [
'entity_type' => $entity->getCommentedEntityTypeId(),
@@ -188,13 +188,13 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
'field_name' => $entity->getFieldName(),
'pid' => $entity->id(),
]),
- );
+ ];
}
if (!$entity->isPublished() && $entity->access('approve')) {
- $links['comment-approve'] = array(
+ $links['comment-approve'] = [
'title' => t('Approve'),
'url' => Url::fromRoute('comment.approve', ['comment' => $entity->id()]),
- );
+ ];
}
if (empty($links) && $this->currentUser->isAnonymous()) {
$links['comment-forbidden']['title'] = $this->commentManager->forbiddenMessage($commented_entity, $entity->getFieldName());
@@ -203,18 +203,18 @@ protected function buildLinks(CommentInterface $entity, EntityInterface $comment
// Add translations link for translation-enabled comment bundles.
if ($this->moduleHandler->moduleExists('content_translation') && $this->access($entity)->isAllowed()) {
- $links['comment-translations'] = array(
+ $links['comment-translations'] = [
'title' => t('Translate'),
'url' => $entity->urlInfo('drupal:content-translation-overview'),
- );
+ ];
}
- return array(
+ return [
'#theme' => 'links__comment__comment',
// The "entity" property is specified to be present, so no need to check.
'#links' => $links,
- '#attributes' => array('class' => array('links', 'inline')),
- );
+ '#attributes' => ['class' => ['links', 'inline']],
+ ];
}
/**
diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php
index 9998e3f..c7cbc18 100644
--- a/core/modules/comment/src/CommentLinkBuilder.php
+++ b/core/modules/comment/src/CommentLinkBuilder.php
@@ -75,7 +75,7 @@ public function __construct(AccountInterface $current_user, CommentManagerInterf
* {@inheritdoc}
*/
public function buildCommentedEntityLinks(FieldableEntityInterface $entity, array &$context) {
- $entity_links = array();
+ $entity_links = [];
$view_mode = $context['view_mode'];
if ($view_mode == 'search_index' || $view_mode == 'search_result' || $view_mode == 'print' || $view_mode == 'rss') {
// Do not add any links if the entity is displayed for:
@@ -83,7 +83,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra
// - constructing a search result excerpt.
// - print.
// - rss.
- return array();
+ return [];
}
$fields = $this->commentManager->getFields($entity->getEntityTypeId());
@@ -92,7 +92,7 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra
if (!$entity->hasField($field_name)) {
continue;
}
- $links = array();
+ $links = [];
$commenting_status = $entity->get($field_name)->status;
if ($commenting_status != CommentItemInterface::HIDDEN) {
// Entity has commenting status open or closed.
@@ -103,23 +103,23 @@ public function buildCommentedEntityLinks(FieldableEntityInterface $entity, arra
// entity is open to new comments, and there currently are none.
if ($this->currentUser->hasPermission('access comments')) {
if (!empty($entity->get($field_name)->comment_count)) {
- $links['comment-comments'] = array(
+ $links['comment-comments'] = [
'title' => $this->formatPlural($entity->get($field_name)->comment_count, '1 comment', '@count comments'),
- 'attributes' => array('title' => $this->t('Jump to the first comment.')),
+ 'attributes' => ['title' => $this->t('Jump to the first comment.')],
'fragment' => 'comments',
'url' => $entity->urlInfo(),
- );
+ ];
if ($this->moduleHandler->moduleExists('history')) {
- $links['comment-new-comments'] = array(
+ $links['comment-new-comments'] = [
'title' => '',
'url' => Url::fromRoute('
' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', array('%label' => $this->entity->label())) . '
'; + $caption .= '' . $this->formatPlural(count($comments), '%label is used by 1 comment on your site. You can not remove this comment type until you have removed all of the %label comments.', '%label is used by @count comments on your site. You may not remove %label until you have removed all of the %label comments.', ['%label' => $this->entity->label()]) . '
'; } if ($caption) { - $form['description'] = array('#markup' => $caption); + $form['description'] = ['#markup' => $caption]; return $form; } else { diff --git a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php index c66e428..5906248 100644 --- a/core/modules/comment/src/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/src/Form/ConfirmDeleteMultiple.php @@ -81,25 +81,25 @@ public function getConfirmText() { public function buildForm(array $form, FormStateInterface $form_state) { $edit = $form_state->getUserInput(); - $form['comments'] = array( + $form['comments'] = [ '#prefix' => '' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the online documentation for the Configuration Manager module.', array(':url' => 'https://www.drupal.org/documentation/administer/config')) . '
'; + $output .= '' . t('The Configuration Manager module provides a user interface for importing and exporting configuration changes between installations of your website in different environments. Configuration is stored in YAML format. For more information, see the online documentation for the Configuration Manager module.', [':url' => 'https://www.drupal.org/documentation/administer/config']) . '
'; $output .= 'foobar
'; - $original_data = array( + $original_data = [ 'foo' => 'foobar
', 'baz' => 'no change', '404' => 'herp', - ); + ]; // Update active storage to have html in config data. $this->config($config_name)->setData($original_data)->save(); @@ -290,7 +290,7 @@ function testImportDiff() { // Load the diff UI and verify that the diff reflects the change. $this->drupalGet('admin/config/development/configuration/sync/diff/' . $config_name); - $this->assertTitle(format_string('View changes of @config_name | Drupal', array('@config_name' => $config_name))); + $this->assertTitle(format_string('View changes of @config_name | Drupal', ['@config_name' => $config_name])); // The following assertions do not use $this::assertEscaped() because // \Drupal\Component\Diff\DiffFormatter adds markup that signifies what has @@ -307,7 +307,7 @@ function testImportDiff() { $this->assertText(Html::escape("404: 'herp'")); // Verify diff colors are displayed. - $result = $this->xpath('//table[contains(@class, :class)]', array(':class' => 'diff')); + $result = $this->xpath('//table[contains(@class, :class)]', [':class' => 'diff']); $this->assertEqual(count($result), 1, "Diff UI is displaying colors."); // Reset data back to original, and remove a key @@ -351,7 +351,7 @@ public function testImportValidation() { $this->drupalGet('admin/config/development/configuration'); $this->assertNoText(t('There are no configuration changes to import.')); - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); // Verify that the validation messages appear. $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); @@ -373,7 +373,7 @@ public function testConfigUninstallConfigException() { $this->assertText('core.extension'); // Import and verify that both do not appear anymore. - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertText('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.'); } @@ -394,11 +394,11 @@ function testImportErrorLog() { $sync = $this->container->get('config.storage.sync'); $uuid = $this->container->get('uuid'); - $values_primary = array( + $values_primary = [ 'uuid' => $uuid->generate(), 'langcode' => 'en', 'status' => TRUE, - 'dependencies' => array(), + 'dependencies' => [], 'id' => 'primary', 'label' => 'Primary', 'weight' => 0, @@ -406,16 +406,16 @@ function testImportErrorLog() { 'size' => NULL, 'size_value' => NULL, 'protected_property' => NULL, - ); + ]; $sync->write($name_primary, $values_primary); - $values_secondary = array( + $values_secondary = [ 'uuid' => $uuid->generate(), 'langcode' => 'en', 'status' => TRUE, // Add a dependency on primary, to ensure that is synced first. - 'dependencies' => array( - 'config' => array($name_primary), - ), + 'dependencies' => [ + 'config' => [$name_primary], + ], 'id' => 'secondary', 'label' => 'Secondary Sync', 'weight' => 0, @@ -423,15 +423,15 @@ function testImportErrorLog() { 'size' => NULL, 'size_value' => NULL, 'protected_property' => NULL, - ); + ]; $sync->write($name_secondary, $values_secondary); // Verify that there are configuration differences to import. $this->drupalGet('admin/config/development/configuration'); $this->assertNoText(t('There are no configuration changes to import.')); // Attempt to import configuration and verify that an error message appears. - $this->drupalPostForm(NULL, array(), t('Import all')); - $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', array('@name' => $name_secondary))); + $this->drupalPostForm(NULL, [], t('Import all')); + $this->assertText(SafeMarkup::format('Deleted and replaced configuration entity "@name"', ['@name' => $name_secondary])); $this->assertText(t('The configuration was imported with errors.')); $this->assertNoText(t('The configuration was imported successfully.')); $this->assertText(t('There are no configuration changes to import.')); @@ -443,42 +443,42 @@ function testImportErrorLog() { * @see \Drupal\Core\Entity\Event\BundleConfigImportValidate */ public function testEntityBundleDelete() { - \Drupal::service('module_installer')->install(array('node')); + \Drupal::service('module_installer')->install(['node']); $this->copyConfig($this->container->get('config.storage'), $this->container->get('config.storage.sync')); $node_type = $this->drupalCreateContentType(); - $node = $this->drupalCreateNode(array('type' => $node_type->id())); + $node = $this->drupalCreateNode(['type' => $node_type->id()]); $this->drupalGet('admin/config/development/configuration'); // The node type, body field and entity displays will be scheduled for // removal. - $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id()))); - $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id()))); + $this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()])); + $this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()])); // Attempt to import configuration and verify that an error message appears // and the node type, body field and entity displays are still scheduled for // removal. - $this->drupalPostForm(NULL, array(), t('Import all')); - $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', array('%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label())); + $this->drupalPostForm(NULL, [], t('Import all')); + $validation_message = t('Entities exist of type %entity_type and %bundle_label %bundle. These entities need to be deleted before importing.', ['%entity_type' => $node->getEntityType()->getLabel(), '%bundle_label' => $node->getEntityType()->getBundleLabel(), '%bundle' => $node_type->label()]); $this->assertRaw($validation_message); - $this->assertText(format_string('node.type.@type', array('@type' => $node_type->id()))); - $this->assertText(format_string('field.field.node.@type.body', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id()))); - $this->assertText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id()))); + $this->assertText(format_string('node.type.@type', ['@type' => $node_type->id()])); + $this->assertText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()])); + $this->assertText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()])); // Delete the node and try to import again. $node->delete(); - $this->drupalPostForm(NULL, array(), t('Import all')); + $this->drupalPostForm(NULL, [], t('Import all')); $this->assertNoRaw($validation_message); $this->assertText(t('There are no configuration changes to import.')); - $this->assertNoText(format_string('node.type.@type', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('field.field.node.@type.body', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('core.entity_view_display.node.@type.default', array('@type' => $node_type->id()))); - $this->assertNoText(format_string('core.entity_form_display.node.@type.default', array('@type' => $node_type->id()))); + $this->assertNoText(format_string('node.type.@type', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('field.field.node.@type.body', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('core.entity_view_display.node.@type.teaser', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('core.entity_view_display.node.@type.default', ['@type' => $node_type->id()])); + $this->assertNoText(format_string('core.entity_form_display.node.@type.default', ['@type' => $node_type->id()])); } /** @@ -508,7 +508,7 @@ public function testExtensionValidation() { $core['theme']['does_not_exist'] = 0; $sync->write('core.extension', $core); - $this->drupalPostForm('admin/config/development/configuration', array(), t('Import all')); + $this->drupalPostForm('admin/config/development/configuration', [], t('Import all')); $this->assertText('The configuration cannot be imported because it failed validation for the following reasons:'); $this->assertText('Unable to uninstall the Text module since the Node module is installed.'); $this->assertText('Unable to uninstall the Classy theme since the Bartik theme is installed.'); diff --git a/core/modules/config/src/Tests/ConfigImportUploadTest.php b/core/modules/config/src/Tests/ConfigImportUploadTest.php index 9836d77..9792213 100644 --- a/core/modules/config/src/Tests/ConfigImportUploadTest.php +++ b/core/modules/config/src/Tests/ConfigImportUploadTest.php @@ -23,12 +23,12 @@ class ConfigImportUploadTest extends WebTestBase { * * @var array */ - public static $modules = array('config'); + public static $modules = ['config']; protected function setUp() { parent::setUp(); - $this->webUser = $this->drupalCreateUser(array('import configuration')); + $this->webUser = $this->drupalCreateUser(['import configuration']); $this->drupalLogin($this->webUser); } @@ -42,7 +42,7 @@ function testImport() { // Attempt to upload a non-tar file. $text_file = current($this->drupalGetTestFiles('text')); - $edit = array('files[import_tarball]' => drupal_realpath($text_file->uri)); + $edit = ['files[import_tarball]' => drupal_realpath($text_file->uri)]; $this->drupalPostForm('admin/config/development/configuration/full/import', $edit, t('Upload')); $this->assertText(t('Could not extract the contents of the tar file')); diff --git a/core/modules/config/src/Tests/ConfigInstallWebTest.php b/core/modules/config/src/Tests/ConfigInstallWebTest.php index 8f9e1a1..79b50a0 100644 --- a/core/modules/config/src/Tests/ConfigInstallWebTest.php +++ b/core/modules/config/src/Tests/ConfigInstallWebTest.php @@ -26,7 +26,7 @@ class ConfigInstallWebTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->adminUser = $this->drupalCreateUser(array('administer modules', 'administer themes', 'administer site configuration')); + $this->adminUser = $this->drupalCreateUser(['administer modules', 'administer themes', 'administer site configuration']); // Ensure the global variable being asserted by this test does not exist; // a previous test executed in this request/process might have set it. @@ -41,7 +41,7 @@ function testIntegrationModuleReinstallation() { $default_configuration_entity = 'config_test.dynamic.config_integration_test'; // Install the config_test module we're integrating with. - \Drupal::service('module_installer')->install(array('config_test')); + \Drupal::service('module_installer')->install(['config_test']); // Verify the configuration does not exist prior to installation. $config_static = $this->config($default_config); @@ -50,7 +50,7 @@ function testIntegrationModuleReinstallation() { $this->assertIdentical($config_entity->isNew(), TRUE); // Install the integration module. - \Drupal::service('module_installer')->install(array('config_integration_test')); + \Drupal::service('module_installer')->install(['config_integration_test']); // Verify that default module config exists. \Drupal::configFactory()->reset($default_config); @@ -73,7 +73,7 @@ function testIntegrationModuleReinstallation() { $this->container->get('config.factory')->reset(); // Disable and uninstall the integration module. - $this->container->get('module_installer')->uninstall(array('config_integration_test')); + $this->container->get('module_installer')->uninstall(['config_integration_test']); // Verify the integration module's config was uninstalled. $config_static = $this->config($default_config); @@ -86,7 +86,7 @@ function testIntegrationModuleReinstallation() { // Reinstall the integration module. try { - \Drupal::service('module_installer')->install(array('config_integration_test')); + \Drupal::service('module_installer')->install(['config_integration_test']); $this->fail('Expected PreExistingConfigException not thrown.'); } catch (PreExistingConfigException $e) { @@ -97,7 +97,7 @@ function testIntegrationModuleReinstallation() { // Delete the configuration entity so that the install will work. $config_entity->delete(); - \Drupal::service('module_installer')->install(array('config_integration_test')); + \Drupal::service('module_installer')->install(['config_integration_test']); // Verify the integration module's config was re-installed. \Drupal::configFactory()->reset($default_config); @@ -122,19 +122,19 @@ public function testPreExistingConfigInstall() { // will install the config_test module first because it is a dependency of // config_install_fail_test. // @see \Drupal\system\Form\ModulesListForm::submitForm() - $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE, 'modules[config_install_fail_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default already exists in active configuration.'); // Uninstall the config_test module to test the confirm form. - $this->drupalPostForm('admin/modules/uninstall', array('uninstall[config_test]' => TRUE), t('Uninstall')); - $this->drupalPostForm(NULL, array(), t('Uninstall')); + $this->drupalPostForm('admin/modules/uninstall', ['uninstall[config_test]' => TRUE], t('Uninstall')); + $this->drupalPostForm(NULL, [], t('Uninstall')); // Try to install config_install_fail_test without selecting config_test. // The user is shown a confirm form because the config_test module is a // dependency. // @see \Drupal\system\Form\ModulesListConfirmForm::submitForm() - $this->drupalPostForm('admin/modules', array('modules[config_install_fail_test][enable]' => TRUE), t('Install')); - $this->drupalPostForm(NULL, array(), t('Continue')); + $this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install')); + $this->drupalPostForm(NULL, [], t('Continue')); $this->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default already exists in active configuration.'); // Test that collection configuration clashes during a module install are @@ -147,7 +147,7 @@ public function testPreExistingConfigInstall() { ->set('label', 'Je suis Charlie') ->save(); - $this->drupalPostForm('admin/modules', array('modules[config_install_fail_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_install_fail_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Configuration install fail test, config_test.dynamic.dotted.default, language/fr/config_test.dynamic.dotted.default already exist in active configuration.'); // Test installing a theme through the UI that has existing configuration. @@ -178,16 +178,16 @@ public function testUnmetDependenciesInstall() { $this->drupalLogin($this->adminUser); // We need to install separately since config_install_dependency_test does // not depend on config_test and order is important. - $this->drupalPostForm('admin/modules', array('modules[config_test][enable]' => TRUE), t('Install')); - $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_test][enable]' => TRUE], t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Config install dependency test due to unmet dependencies: config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test, config_test.dynamic.dotted.english)'); - $this->drupalPostForm('admin/modules', array('modules[config_test_language][enable]' => TRUE), t('Install')); - $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_test_language][enable]' => TRUE], t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install')); $this->assertRaw('Unable to install Config install dependency test due to unmet dependencies: config_test.dynamic.other_module_test_with_dependency (config_other_module_config_test)'); - $this->drupalPostForm('admin/modules', array('modules[config_other_module_config_test][enable]' => TRUE), t('Install')); - $this->drupalPostForm('admin/modules', array('modules[config_install_dependency_test][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_other_module_config_test][enable]' => TRUE], t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config_install_dependency_test][enable]' => TRUE], t('Install')); $this->rebuildContainer(); $this->assertTrue(entity_load('config_test', 'other_module_test_with_dependency'), 'The config_test.dynamic.other_module_test_with_dependency configuration has been created during install.'); } @@ -197,12 +197,12 @@ public function testUnmetDependenciesInstall() { */ public function testConfigModuleRequirements() { $this->drupalLogin($this->adminUser); - $this->drupalPostForm('admin/modules', array('modules[config][enable]' => TRUE), t('Install')); + $this->drupalPostForm('admin/modules', ['modules[config][enable]' => TRUE], t('Install')); $directory = config_get_config_directory(CONFIG_SYNC_DIRECTORY); file_unmanaged_delete_recursive($directory); $this->drupalGet('/admin/reports/status'); - $this->assertRaw(t('The directory %directory does not exist.', array('%directory' => $directory))); + $this->assertRaw(t('The directory %directory does not exist.', ['%directory' => $directory])); file_prepare_directory($directory, FILE_CREATE_DIRECTORY); \Drupal::service('file_system')->chmod($directory, 0555); diff --git a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php index 53f6164..16cff0a 100644 --- a/core/modules/config/src/Tests/ConfigSingleImportExportTest.php +++ b/core/modules/config/src/Tests/ConfigSingleImportExportTest.php @@ -39,7 +39,7 @@ public function testImport() { $storage = \Drupal::entityManager()->getStorage('config_test'); $uuid = \Drupal::service('uuid'); - $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); + $this->drupalLogin($this->drupalCreateUser(['import configuration'])); // Attempt an import with invalid YAML. $edit = [ @@ -57,20 +57,20 @@ public function testImport() { style: '' status: '1' EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; // Attempt an import with a missing ID. $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', array('@id_key' => 'id', '@entity_type' => 'Test configuration'))); + $this->assertText(t('Missing ID key "@id_key" for this @entity_type import.', ['@id_key' => 'id', '@entity_type' => 'Test configuration'])); // Perform an import with no specified UUID and a unique ID. $this->assertNull($storage->load('first')); $edit['import'] = "id: first\n" . $edit['import']; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'first', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'first', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $entity = $storage->load('first'); $this->assertIdentical($entity->label(), 'First'); $this->assertIdentical($entity->id(), 'first'); @@ -89,8 +89,8 @@ public function testImport() { // Attempt an import with a custom ID. $edit['custom_entity_id'] = 'custom_id'; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'custom_id', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'custom_id', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $this->assertRaw(t('The configuration was imported successfully.')); // Perform an import with a unique ID and UUID. @@ -101,15 +101,15 @@ public function testImport() { style: '' status: '0' EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; $second_uuid = $uuid->generate(); $edit['import'] .= "\nuuid: " . $second_uuid; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to create a new %name @type?', array('%name' => 'second', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to create a new %name @type?', ['%name' => 'second', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $entity = $storage->load('second'); $this->assertRaw(t('The configuration was imported successfully.')); $this->assertIdentical($entity->label(), 'Second'); @@ -126,13 +126,13 @@ public function testImport() { style: '' status: '0' EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => 'second', '@type' => 'test configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => 'second', '@type' => 'test configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $entity = $storage->load('second'); $this->assertRaw(t('The configuration was imported successfully.')); $this->assertIdentical($entity->label(), 'Second updated'); @@ -149,10 +149,10 @@ public function testImport() { module: - does_not_exist EOD; - $edit = array( + $edit = [ 'config_type' => 'config_test', 'import' => $import, - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->assertRaw(t('Configuration %name depends on the %owner module that will not be installed after import.', ['%name' => 'config_test.dynamic.second', '%owner' => 'does_not_exist'])); } @@ -161,20 +161,20 @@ public function testImport() { * Tests importing a simple configuration file. */ public function testImportSimpleConfiguration() { - $this->drupalLogin($this->drupalCreateUser(array('import configuration'))); + $this->drupalLogin($this->drupalCreateUser(['import configuration'])); $config = $this->config('system.site')->set('name', 'Test simple import'); // Place branding block with site name into header region. $this->drupalPlaceBlock('system_branding_block', ['region' => 'header']); - $edit = array( + $edit = [ 'config_type' => 'system.simple', 'config_name' => $config->getName(), 'import' => Yaml::encode($config->get()), - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); - $this->assertRaw(t('Are you sure you want to update the %name @type?', array('%name' => $config->getName(), '@type' => 'simple configuration'))); - $this->drupalPostForm(NULL, array(), t('Confirm')); + $this->assertRaw(t('Are you sure you want to update the %name @type?', ['%name' => $config->getName(), '@type' => 'simple configuration'])); + $this->drupalPostForm(NULL, [], t('Confirm')); $this->drupalGet(''); $this->assertText('Test simple import'); @@ -183,11 +183,11 @@ public function testImportSimpleConfiguration() { $config_data = $this->config('core.extension')->get(); // Simulate uninstalling the Config module. unset($config_data['module']['config']); - $edit = array( + $edit = [ 'config_type' => 'system.simple', 'config_name' => 'core.extension', 'import' => Yaml::encode($config_data), - ); + ]; $this->drupalPostForm('admin/config/development/configuration/single/import', $edit, t('Import')); $this->assertText(t('Can not uninstall the Configuration module as part of a configuration synchronization through the user interface.')); @@ -197,14 +197,14 @@ public function testImportSimpleConfiguration() { * Tests exporting a single configuration file. */ public function testExport() { - $this->drupalLogin($this->drupalCreateUser(array('export configuration'))); + $this->drupalLogin($this->drupalCreateUser(['export configuration'])); $this->drupalGet('admin/config/development/configuration/single/export/system.simple'); $this->assertFieldByXPath('//select[@name="config_type"]//option[@selected="selected"]', t('Simple configuration'), 'The simple configuration option is selected when specified in the URL.'); // Spot check several known simple configuration files. $element = $this->xpath('//select[@name="config_name"]'); $options = $this->getAllOptions($element[0]); - $expected_options = array('system.site', 'user.settings'); + $expected_options = ['system.site', 'user.settings']; foreach ($options as &$option) { $option = (string) $option; } diff --git a/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php b/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php index 1aa4c9a..ba67960 100644 --- a/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php +++ b/core/modules/config/src/Tests/LanguageNegotiationFormOverrideTest.php @@ -12,7 +12,7 @@ */ class LanguageNegotiationFormOverrideTest extends WebTestBase { - public static $modules = array('language', 'locale', 'locale_test'); + public static $modules = ['language', 'locale', 'locale_test']; /** * Tests that overrides do not affect language-negotiation form values. @@ -23,16 +23,16 @@ public function testFormWithOverride() { $overridden_value_es = 'loquesea'; // Set up an override. - $settings['config']['language.negotiation']['url']['prefixes'] = (object) array( - 'value' => array('en' => $overridden_value_en, 'es' => $overridden_value_es), + $settings['config']['language.negotiation']['url']['prefixes'] = (object) [ + 'value' => ['en' => $overridden_value_en, 'es' => $overridden_value_es], 'required' => TRUE, - ); + ]; $this->writeSettings($settings); // Add predefined language. - $edit = array( + $edit = [ 'predefined_langcode' => 'es', - ); + ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); // Overridden string for language-negotiation should not exist in the form. diff --git a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php index da3a9f1..76714a5 100644 --- a/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_collection_install_test/src/EventSubscriber.php @@ -33,7 +33,7 @@ public function __construct(StateInterface $state) { * The configuration collection info event. */ public function addCollections(ConfigCollectionInfo $collection_info) { - $collections = $this->state->get('config_collection_install_test.collection_names', array()); + $collections = $this->state->get('config_collection_install_test.collection_names', []); foreach ($collections as $collection) { $collection_info->addCollection($collection); } @@ -43,7 +43,7 @@ public function addCollections(ConfigCollectionInfo $collection_info) { * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::COLLECTION_INFO][] = array('addCollections'); + $events[ConfigEvents::COLLECTION_INFO][] = ['addCollections']; return $events; } diff --git a/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php b/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php index 2345d55..8d21ee4 100644 --- a/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php +++ b/core/modules/config/tests/config_entity_static_cache_test/src/ConfigOverrider.php @@ -15,11 +15,11 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface { * {@inheritdoc} */ public function loadOverrides($names) { - return array( - 'config_test.dynamic.test_1' => array( + return [ + 'config_test.dynamic.test_1' => [ 'label' => 'Overridden label', - ) - ); + ] + ]; } /** diff --git a/core/modules/config/tests/config_events_test/src/EventSubscriber.php b/core/modules/config/tests/config_events_test/src/EventSubscriber.php index bfa70db..39e8eb8 100644 --- a/core/modules/config/tests/config_events_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_events_test/src/EventSubscriber.php @@ -37,21 +37,21 @@ public function __construct(StateInterface $state) { */ public function configEventRecorder(ConfigCrudEvent $event, $name) { $config = $event->getConfig(); - $this->state->set('config_events_test.event', array( + $this->state->set('config_events_test.event', [ 'event_name' => $name, 'current_config_data' => $config->get(), 'original_config_data' => $config->getOriginal(), 'raw_config_data' => $config->getRawData() - )); + ]); } /** * {@inheritdoc} */ static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('configEventRecorder'); - $events[ConfigEvents::DELETE][] = array('configEventRecorder'); - $events[ConfigEvents::RENAME][] = array('configEventRecorder'); + $events[ConfigEvents::SAVE][] = ['configEventRecorder']; + $events[ConfigEvents::DELETE][] = ['configEventRecorder']; + $events[ConfigEvents::RENAME][] = ['configEventRecorder']; return $events; } diff --git a/core/modules/config/tests/config_import_test/src/EventSubscriber.php b/core/modules/config/tests/config_import_test/src/EventSubscriber.php index f4ae97f..e0ef923 100644 --- a/core/modules/config/tests/config_import_test/src/EventSubscriber.php +++ b/core/modules/config/tests/config_import_test/src/EventSubscriber.php @@ -88,14 +88,14 @@ public function onConfigImporterMissingContentTwo(MissingContentEvent $event) { public function onConfigSave(ConfigCrudEvent $event) { $config = $event->getConfig(); if ($config->getName() == 'action.settings') { - $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', array()); + $values = $this->state->get('ConfigImportUITest.action.settings.recursion_limit', []); $values[] = $config->get('recursion_limit'); $this->state->set('ConfigImportUITest.action.settings.recursion_limit', $values); } if ($config->getName() == 'core.extension') { - $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', array()); - $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', array()); + $installed = $this->state->get('ConfigImportUITest.core.extension.modules_installed', []); + $uninstalled = $this->state->get('ConfigImportUITest.core.extension.modules_uninstalled', []); $original = $config->getOriginal('module'); $data = $config->get('module'); $install = array_diff_key($data, $original); @@ -132,10 +132,10 @@ public function onConfigDelete(ConfigCrudEvent $event) { * An array of event listener definitions. */ static function getSubscribedEvents() { - $events[ConfigEvents::SAVE][] = array('onConfigSave', 40); - $events[ConfigEvents::DELETE][] = array('onConfigDelete', 40); - $events[ConfigEvents::IMPORT_VALIDATE] = array('onConfigImporterValidate'); - $events[ConfigEvents::IMPORT_MISSING_CONTENT] = array(array('onConfigImporterMissingContentOne'), array('onConfigImporterMissingContentTwo', -100)); + $events[ConfigEvents::SAVE][] = ['onConfigSave', 40]; + $events[ConfigEvents::DELETE][] = ['onConfigDelete', 40]; + $events[ConfigEvents::IMPORT_VALIDATE] = ['onConfigImporterValidate']; + $events[ConfigEvents::IMPORT_MISSING_CONTENT] = [['onConfigImporterMissingContentOne'], ['onConfigImporterMissingContentTwo', -100]]; return $events; } diff --git a/core/modules/config/tests/config_override_test/src/ConfigOverrider.php b/core/modules/config/tests/config_override_test/src/ConfigOverrider.php index 895f041..c8ffc69 100644 --- a/core/modules/config/tests/config_override_test/src/ConfigOverrider.php +++ b/core/modules/config/tests/config_override_test/src/ConfigOverrider.php @@ -14,13 +14,13 @@ class ConfigOverrider implements ConfigFactoryOverrideInterface { * {@inheritdoc} */ public function loadOverrides($names) { - $overrides = array(); + $overrides = []; if (!empty($GLOBALS['config_test_run_module_overrides'])) { if (in_array('system.site', $names)) { - $overrides = $overrides + array('system.site' => array('name' => 'ZOMG overridden site name')); + $overrides = $overrides + ['system.site' => ['name' => 'ZOMG overridden site name']]; } if (in_array('config_override_test.new', $names)) { - $overrides = $overrides + array('config_override_test.new' => array('module' => 'override')); + $overrides = $overrides + ['config_override_test.new' => ['module' => 'override']]; } } return $overrides; diff --git a/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php b/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php index 6f0b12d..b8109db 100644 --- a/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php +++ b/core/modules/config/tests/config_override_test/src/ConfigOverriderLowPriority.php @@ -15,17 +15,17 @@ class ConfigOverriderLowPriority implements ConfigFactoryOverrideInterface { * {@inheritdoc} */ public function loadOverrides($names) { - $overrides = array(); + $overrides = []; if (!empty($GLOBALS['config_test_run_module_overrides'])) { if (in_array('system.site', $names)) { - $overrides = array('system.site' => - array( + $overrides = ['system.site' => + [ 'name' => 'Should not apply because of higher priority listener', // This override should apply because it is not overridden by the // higher priority listener. 'slogan' => 'Yay for overrides!', - ) - ); + ] + ]; } } return $overrides; diff --git a/core/modules/config/tests/config_test/src/ConfigTestController.php b/core/modules/config/tests/config_test/src/ConfigTestController.php index d60c62e..6799dc1 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestController.php +++ b/core/modules/config/tests/config_test/src/ConfigTestController.php @@ -21,7 +21,7 @@ class ConfigTestController extends ControllerBase { * The title for the ConfigTest edit form. */ public function editTitle(ConfigTest $config_test) { - return $this->t('Edit %label', array('%label' => $config_test->label())); + return $this->t('Edit %label', ['%label' => $config_test->label()]); } /** @@ -35,7 +35,7 @@ public function editTitle(ConfigTest $config_test) { */ function enable(ConfigTest $config_test) { $config_test->enable()->save(); - return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE))); + return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE])); } /** @@ -49,7 +49,7 @@ function enable(ConfigTest $config_test) { */ function disable(ConfigTest $config_test) { $config_test->disable()->save(); - return new RedirectResponse($config_test->url('collection', array('absolute' => TRUE))); + return new RedirectResponse($config_test->url('collection', ['absolute' => TRUE])); } } diff --git a/core/modules/config/tests/config_test/src/ConfigTestForm.php b/core/modules/config/tests/config_test/src/ConfigTestForm.php index 8384e6a..6a56c3d 100644 --- a/core/modules/config/tests/config_test/src/ConfigTestForm.php +++ b/core/modules/config/tests/config_test/src/ConfigTestForm.php @@ -18,33 +18,33 @@ public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); $entity = $this->entity; - $form['label'] = array( + $form['label'] = [ '#type' => 'textfield', '#title' => 'Label', '#default_value' => $entity->label(), '#required' => TRUE, - ); - $form['id'] = array( + ]; + $form['id'] = [ '#type' => 'machine_name', '#default_value' => $entity->id(), '#required' => TRUE, - '#machine_name' => array( + '#machine_name' => [ 'exists' => [$this, 'exists'], 'replace_pattern' => '[^a-z0-9_.]+', - ), - ); - $form['weight'] = array( + ], + ]; + $form['weight'] = [ '#type' => 'weight', '#title' => 'Weight', '#default_value' => $entity->get('weight'), - ); - $form['style'] = array( + ]; + $form['style'] = [ '#type' => 'select', '#title' => 'Image style', - '#options' => array(), + '#options' => [], '#default_value' => $entity->get('style'), '#access' => FALSE, - ); + ]; if ($this->moduleHandler->moduleExists('image')) { $form['style']['#access'] = TRUE; $form['style']['#options'] = image_style_options(); @@ -55,61 +55,61 @@ public function form(array $form, FormStateInterface $form_state) { // state. $size = $entity->get('size'); - $form['size_wrapper'] = array( + $form['size_wrapper'] = [ '#type' => 'container', - '#attributes' => array( + '#attributes' => [ 'id' => 'size-wrapper', - ), - ); - $form['size_wrapper']['size'] = array( + ], + ]; + $form['size_wrapper']['size'] = [ '#type' => 'select', '#title' => 'Size', - '#options' => array( + '#options' => [ 'custom' => 'Custom', - ), + ], '#empty_option' => '- None -', '#default_value' => $size, - '#ajax' => array( + '#ajax' => [ 'callback' => '::updateSize', 'wrapper' => 'size-wrapper', - ), - ); - $form['size_wrapper']['size_submit'] = array( + ], + ]; + $form['size_wrapper']['size_submit'] = [ '#type' => 'submit', '#value' => t('Change size'), - '#attributes' => array( - 'class' => array('js-hide'), - ), - '#submit' => array(array(get_class($this), 'changeSize')), - ); - $form['size_wrapper']['size_value'] = array( + '#attributes' => [ + 'class' => ['js-hide'], + ], + '#submit' => [[get_class($this), 'changeSize']], + ]; + $form['size_wrapper']['size_value'] = [ '#type' => 'select', '#title' => 'Custom size value', - '#options' => array( + '#options' => [ 'small' => 'Small', 'medium' => 'Medium', 'large' => 'Large', - ), + ], '#default_value' => $entity->get('size_value'), '#access' => !empty($size), - ); + ]; - $form['langcode'] = array( + $form['langcode'] = [ '#type' => 'language_select', '#title' => t('Language'), '#languages' => LanguageInterface::STATE_ALL, '#default_value' => $entity->language()->getId(), - ); + ]; - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array( + $form['actions'] = ['#type' => 'actions']; + $form['actions']['submit'] = [ '#type' => 'submit', '#value' => 'Save', - ); - $form['actions']['delete'] = array( + ]; + $form['actions']['delete'] = [ '#type' => 'submit', '#value' => 'Delete', - ); + ]; return $form; } @@ -136,10 +136,10 @@ public function save(array $form, FormStateInterface $form_state) { $status = $entity->save(); if ($status === SAVED_UPDATED) { - drupal_set_message(format_string('%label configuration has been updated.', array('%label' => $entity->label()))); + drupal_set_message(format_string('%label configuration has been updated.', ['%label' => $entity->label()])); } else { - drupal_set_message(format_string('%label configuration has been created.', array('%label' => $entity->label()))); + drupal_set_message(format_string('%label configuration has been created.', ['%label' => $entity->label()])); } $form_state->setRedirectUrl($this->entity->urlInfo('collection')); diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php index 10914f0..ca3b354 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigQueryTest.php @@ -38,6 +38,6 @@ class ConfigQueryTest extends ConfigTest { * * @var array */ - public $array = array(); + public $array = []; } diff --git a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php index f19eb65..1bd1d8d 100644 --- a/core/modules/config/tests/config_test/src/Entity/ConfigTest.php +++ b/core/modules/config/tests/config_test/src/Entity/ConfigTest.php @@ -88,10 +88,10 @@ public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) public function postSave(EntityStorageInterface $storage, $update = TRUE) { // Used to test secondary writes during config sync. if ($this->id() == 'primary') { - $secondary = $storage->create(array( + $secondary = $storage->create([ 'id' => 'secondary', 'label' => 'Secondary Default', - )); + ]); $secondary->save(); } if ($this->id() == 'deleter') { @@ -126,7 +126,7 @@ public function onDependencyRemoval(array $dependencies) { if (!isset($this->dependencies['enforced']['config'])) { return $changed; } - $fix_deps = \Drupal::state()->get('config_test.fix_dependencies', array()); + $fix_deps = \Drupal::state()->get('config_test.fix_dependencies', []); foreach ($dependencies['config'] as $entity) { if (in_array($entity->getConfigDependencyName(), $fix_deps)) { $key = array_search($entity->getConfigDependencyName(), $this->dependencies['enforced']['config']); diff --git a/core/modules/config/tests/config_test/src/TestInstallStorage.php b/core/modules/config/tests/config_test/src/TestInstallStorage.php index 074e99c..e3c4918 100644 --- a/core/modules/config/tests/config_test/src/TestInstallStorage.php +++ b/core/modules/config/tests/config_test/src/TestInstallStorage.php @@ -20,7 +20,7 @@ protected function getAllFolders() { if (!isset($this->folders)) { $this->folders = $this->getCoreNames(); $listing = new ExtensionDiscovery(\Drupal::root()); - $listing->setProfileDirectories(array()); + $listing->setProfileDirectories([]); $this->folders += $this->getComponentNames($listing->scan('profile')); $this->folders += $this->getComponentNames($listing->scan('module')); $this->folders += $this->getComponentNames($listing->scan('theme')); diff --git a/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php b/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php index c243e9a..ba80401 100644 --- a/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigDependencyWebTest.php @@ -22,7 +22,7 @@ class ConfigDependencyWebTest extends BrowserTestBase { * * @var array */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests ConfigDependencyDeleteFormTrait. @@ -36,10 +36,10 @@ function testConfigDependencyDeleteFormTrait() { $storage = $this->container->get('entity.manager')->getStorage('config_test'); // Entity1 will be deleted by the test. $entity1 = $storage->create( - array( + [ 'id' => 'entity1', 'label' => 'Entity One', - ) + ] ); $entity1->save(); @@ -47,14 +47,14 @@ function testConfigDependencyDeleteFormTrait() { // \Drupal\config_test\Entity::onDependencyRemoval() will remove the // dependency before config entities are deleted. $entity2 = $storage->create( - array( + [ 'id' => 'entity2', - 'dependencies' => array( - 'enforced' => array( - 'config' => array($entity1->getConfigDependencyName()), - ), - ), - ) + 'dependencies' => [ + 'enforced' => [ + 'config' => [$entity1->getConfigDependencyName()], + ], + ], + ] ); $entity2->save(); @@ -65,47 +65,47 @@ function testConfigDependencyDeleteFormTrait() { $this->assertNoText(t('Configuration updates'), 'No configuration updates found.'); $this->assertText(t('Configuration deletions'), 'Configuration deletions found.'); $this->assertText($entity2->id(), 'Entity2 id found'); - $this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete'); + $this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete'); $storage->resetCache(); $this->assertFalse($storage->loadMultiple([$entity1->id(), $entity2->id()]), 'Test entities deleted'); // Set a more complicated test where dependencies will be fixed. // Entity1 will be deleted by the test. $entity1 = $storage->create( - array( + [ 'id' => 'entity1', - ) + ] ); $entity1->save(); - \Drupal::state()->set('config_test.fix_dependencies', array($entity1->getConfigDependencyName())); + \Drupal::state()->set('config_test.fix_dependencies', [$entity1->getConfigDependencyName()]); // Entity2 has a dependency on Entity1 but it can be fixed because // \Drupal\config_test\Entity::onDependencyRemoval() will remove the // dependency before config entities are deleted. $entity2 = $storage->create( - array( + [ 'id' => 'entity2', 'label' => 'Entity Two', - 'dependencies' => array( - 'enforced' => array( - 'config' => array($entity1->getConfigDependencyName()), - ), - ), - ) + 'dependencies' => [ + 'enforced' => [ + 'config' => [$entity1->getConfigDependencyName()], + ], + ], + ] ); $entity2->save(); // Entity3 will be unchanged because it is dependent on Entity2 which can // be fixed. $entity3 = $storage->create( - array( + [ 'id' => 'entity3', - 'dependencies' => array( - 'enforced' => array( - 'config' => array($entity2->getConfigDependencyName()), - ), - ), - ) + 'dependencies' => [ + 'enforced' => [ + 'config' => [$entity2->getConfigDependencyName()], + ], + ], + ] ); $entity3->save(); @@ -115,12 +115,12 @@ function testConfigDependencyDeleteFormTrait() { $this->assertNoText($entity2->id(), 'Entity2 id not found'); $this->assertText($entity2->label(), 'Entity2 label not found'); $this->assertNoText($entity3->id(), 'Entity3 id not found'); - $this->drupalPostForm($entity1->urlInfo('delete-form'), array(), 'Delete'); + $this->drupalPostForm($entity1->urlInfo('delete-form'), [], 'Delete'); $storage->resetCache(); $this->assertFalse($storage->load('entity1'), 'Test entity 1 deleted'); $entity2 = $storage->load('entity2'); $this->assertTrue($entity2, 'Entity 2 not deleted'); - $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], array(), 'Entity 2 dependencies updated to remove dependency on Entity1.'); + $this->assertEqual($entity2->calculateDependencies()->getDependencies()['config'], [], 'Entity 2 dependencies updated to remove dependency on Entity1.'); $entity3 = $storage->load('entity3'); $this->assertTrue($entity3, 'Entity 3 not deleted'); $this->assertEqual($entity3->calculateDependencies()->getDependencies()['config'], [$entity2->getConfigDependencyName()], 'Entity 3 still depends on Entity 2.'); diff --git a/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php b/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php index 417e9f1..7482935 100644 --- a/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php +++ b/core/modules/config/tests/src/Functional/ConfigDraggableListBuilderTest.php @@ -15,13 +15,13 @@ class ConfigDraggableListBuilderTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Test draggable lists. */ public function testDraggableList() { - $this->drupalLogin($this->drupalCreateUser(array('administer permissions'))); + $this->drupalLogin($this->drupalCreateUser(['administer permissions'])); // Create more than 50 roles. for ($i = 0; $i < 51; $i++) { diff --git a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php index 6c40ded..5d99252 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityListMultilingualTest.php @@ -17,7 +17,7 @@ class ConfigEntityListMultilingualTest extends BrowserTestBase { * * @var array */ - public static $modules = array('config_test', 'language', 'block'); + public static $modules = ['config_test', 'language', 'block']; /** * {@inheritdoc} @@ -36,7 +36,7 @@ protected function setUp() { */ function testListUI() { // Log in as an administrative user to access the full menu trail. - $this->drupalLogin($this->drupalCreateUser(array('access administration pages', 'administer site configuration'))); + $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration'])); // Get the list page. $this->drupalGet('admin/structure/config_test'); @@ -44,11 +44,11 @@ function testListUI() { // Add a new entity using the action link. $this->clickLink('Add test configuration'); - $edit = array( + $edit = [ 'label' => 'Antilop', 'id' => 'antilop', 'langcode' => 'hu', - ); + ]; $this->drupalPostForm(NULL, $edit, t('Save')); // Ensure that operations for editing the Hungarian entity appear in English. $this->assertLinkByHref('admin/structure/config_test/manage/antilop'); diff --git a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php index 9ae9412..4ad4d59 100644 --- a/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php +++ b/core/modules/config/tests/src/Functional/ConfigEntityStatusUITest.php @@ -16,7 +16,7 @@ class ConfigEntityStatusUITest extends BrowserTestBase { * * @var array */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests status operations. @@ -25,10 +25,10 @@ function testCRUD() { $this->drupalLogin($this->drupalCreateUser(['administer site configuration'])); $id = strtolower($this->randomMachineName()); - $edit = array( + $edit = [ 'id' => $id, 'label' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm('admin/structure/config_test/add', $edit, 'Save'); $entity = entity_load('config_test', $id); diff --git a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php index 9ed75a4..88218b9 100644 --- a/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php +++ b/core/modules/config/tests/src/Functional/ConfigInstallProfileOverrideTest.php @@ -31,21 +31,21 @@ class ConfigInstallProfileOverrideTest extends BrowserTestBase { function testInstallProfileConfigOverwrite() { $config_name = 'system.cron'; // The expected configuration from the system module. - $expected_original_data = array( - 'threshold' => array( + $expected_original_data = [ + 'threshold' => [ 'requirements_warning' => 172800, 'requirements_error' => 1209600, - ), + ], 'logging' => 1, - ); + ]; // The expected active configuration altered by the install profile. - $expected_profile_data = array( - 'threshold' => array( + $expected_profile_data = [ + 'threshold' => [ 'requirements_warning' => 259200, 'requirements_error' => 1209600, - ), + ], 'logging' => 1, - ); + ]; $expected_profile_data['_core']['default_config_hash'] = Crypt::hashBase64(serialize($expected_profile_data)); // Verify that the original data matches. We have to read the module config diff --git a/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php b/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php index 5aa194e..5fdd1a1 100644 --- a/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php +++ b/core/modules/config/tests/src/Functional/ConfigLanguageOverrideWebTest.php @@ -35,18 +35,18 @@ protected function setUp() { * Tests translating the site name. */ function testSiteNameTranslation() { - $adminUser = $this->drupalCreateUser(array('administer site configuration', 'administer languages')); + $adminUser = $this->drupalCreateUser(['administer site configuration', 'administer languages']); $this->drupalLogin($adminUser); // Add a custom language. $langcode = 'xx'; $name = $this->randomMachineName(16); - $edit = array( + $edit = [ 'predefined_langcode' => 'custom', 'langcode' => $langcode, 'label' => $name, 'direction' => LanguageInterface::DIRECTION_LTR, - ); + ]; $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add custom language')); \Drupal::languageManager() ->getLanguageConfigOverride($langcode, 'system.site') diff --git a/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php b/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php index e1d0d8d..a996760 100644 --- a/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php +++ b/core/modules/config/tests/src/Functional/ConfigOtherModuleTest.php @@ -87,14 +87,14 @@ public function testInstallConfigEntityModuleFirst() { public function testUninstall() { $this->installModule('views'); $storage = $this->container->get('entity_type.manager')->getStorage('view'); - $storage->resetCache(array('frontpage')); + $storage->resetCache(['frontpage']); $this->assertTrue($storage->load('frontpage') === NULL, 'After installing Views, frontpage view which is dependant on the Node and Views modules does not exist.'); $this->installModule('node'); - $storage->resetCache(array('frontpage')); + $storage->resetCache(['frontpage']); $this->assertTrue($storage->load('frontpage') !== NULL, 'After installing Node, frontpage view which is dependant on the Node and Views modules exists.'); $this->uninstallModule('node'); $storage = $this->container->get('entity_type.manager')->getStorage('view'); - $storage->resetCache(array('frontpage')); + $storage->resetCache(['frontpage']); $this->assertTrue($storage->load('frontpage') === NULL, 'After uninstalling Node, frontpage view which is dependant on the Node and Views modules does not exist.'); } @@ -105,7 +105,7 @@ public function testUninstall() { * The module name. */ protected function installModule($module) { - $this->container->get('module_installer')->install(array($module)); + $this->container->get('module_installer')->install([$module]); $this->container = \Drupal::getContainer(); } @@ -116,7 +116,7 @@ protected function installModule($module) { * The module name. */ protected function uninstallModule($module) { - $this->container->get('module_installer')->uninstall(array($module)); + $this->container->get('module_installer')->uninstall([$module]); $this->container = \Drupal::getContainer(); } diff --git a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php index bab8a3e..189d78f 100644 --- a/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php +++ b/core/modules/config/tests/src/Functional/SchemaConfigListenerWebTest.php @@ -15,7 +15,7 @@ class SchemaConfigListenerWebTest extends BrowserTestBase { /** * {@inheritdoc} */ - public static $modules = array('config_test'); + public static $modules = ['config_test']; /** * Tests \Drupal\Core\Config\Development\ConfigSchemaChecker. diff --git a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php index 7dd8d7d..0bfb32e 100644 --- a/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php +++ b/core/modules/config/tests/src/Unit/Menu/ConfigLocalTasksTest.php @@ -12,7 +12,7 @@ class ConfigLocalTasksTest extends LocalTaskIntegrationTestBase { protected function setUp() { - $this->directoryList = array('config' => 'core/modules/config'); + $this->directoryList = ['config' => 'core/modules/config']; parent::setUp(); } @@ -29,13 +29,13 @@ public function testConfigAdminLocalTasks($route, $expected) { * Provides a list of routes to test. */ public function getConfigAdminRoutes() { - return array( - array('config.sync', array(array('config.sync', 'config.import', 'config.export'))), - array('config.import_full', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))), - array('config.import_single', array(array('config.sync', 'config.import', 'config.export'), array('config.import_full', 'config.import_single'))), - array('config.export_full', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))), - array('config.export_single', array(array('config.sync', 'config.import', 'config.export'), array('config.export_full', 'config.export_single'))), - ); + return [ + ['config.sync', [['config.sync', 'config.import', 'config.export']]], + ['config.import_full', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]], + ['config.import_single', [['config.sync', 'config.import', 'config.export'], ['config.import_full', 'config.import_single']]], + ['config.export_full', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]], + ['config.export_single', [['config.sync', 'config.import', 'config.export'], ['config.export_full', 'config.export_single']]], + ]; } } diff --git a/core/modules/config_translation/config_translation.api.php b/core/modules/config_translation/config_translation.api.php index f2ee4a2..f97e259 100644 --- a/core/modules/config_translation/config_translation.api.php +++ b/core/modules/config_translation/config_translation.api.php @@ -50,14 +50,14 @@ function hook_config_translation_info(&$info) { // Make sure entity type has field UI enabled and has a base route. if ($entity_type->get('field_ui_base_route') && !empty($base_route)) { - $info[$entity_type_id . '_fields'] = array( + $info[$entity_type_id . '_fields'] = [ 'base_route_name' => 'entity.field_config.' . $entity_type_id . '_field_edit_form', 'entity_type' => 'field_config', 'title' => t('Title'), 'class' => '\Drupal\config_translation\ConfigFieldMapper', 'base_entity_type' => $entity_type_id, 'weight' => 10, - ); + ]; } } } diff --git a/core/modules/config_translation/config_translation.module b/core/modules/config_translation/config_translation.module index d018d64..344d90e 100644 --- a/core/modules/config_translation/config_translation.module +++ b/core/modules/config_translation/config_translation.module @@ -18,15 +18,15 @@ function config_translation_help($route_name, RouteMatchInterface $route_match) case 'help.page.config_translation': $output = ''; $output .= '' . t('The Configuration Translation module allows you to translate configuration text; for example, the site name, vocabularies, menus, or date formats. Together with the modules Language, Content Translation, and Interface Translation, it allows you to build multilingual websites. For more information, see the online documentation for the Configuration Translation module.', array(':doc_url' => 'https://www.drupal.org/documentation/modules/config_translation', ':config' => \Drupal::url('help.page', array('name' => 'config')), ':language' => \Drupal::url('help.page', array('name' => 'language')), ':locale' => \Drupal::url('help.page', array('name' => 'locale')), ':content-translation' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', array('name' => 'content_translation')) : '#')) . '
'; + $output .= '' . t('The Configuration Translation module allows you to translate configuration text; for example, the site name, vocabularies, menus, or date formats. Together with the modules Language, Content Translation, and Interface Translation, it allows you to build multilingual websites. For more information, see the online documentation for the Configuration Translation module.', [':doc_url' => 'https://www.drupal.org/documentation/modules/config_translation', ':config' => \Drupal::url('help.page', ['name' => 'config']), ':language' => \Drupal::url('help.page', ['name' => 'language']), ':locale' => \Drupal::url('help.page', ['name' => 'locale']), ':content-translation' => (\Drupal::moduleHandler()->moduleExists('content_translation')) ? \Drupal::url('help.page', ['name' => 'content_translation']) : '#']) . '
'; $output .= 'Hello World - FR
', 'translation[config_names][config_translation_test.content][animals][0]' => 'kitten - FR', 'translation[config_names][config_translation_test.content][animals][1]' => 'llama - FR', 'translation[config_names][config_translation_test.content][animals][2]' => 'elephant - FR', - ); + ]; $this->drupalPostForm('admin/config/media/file-system/translate/fr/add', $edit, t('Save translation')); $this->container->get('language.config_factory_override') - ->setLanguage(new Language(array('id' => 'fr'))); + ->setLanguage(new Language(['id' => 'fr'])); - $expected = array( + $expected = [ 'kitten - FR', 'llama - FR', 'elephant - FR', - ); + ]; $actual = $config_factory ->get('config_translation_test.content') ->get('animals'); @@ -947,10 +947,10 @@ public function testTextFormatTranslation() { /** @var \Drupal\Core\Config\ConfigFactoryInterface $config_factory */ $config_factory = $this->container->get('config.factory'); - $expected = array( + $expected = [ 'value' => 'Hello World
', 'format' => 'plain_text', - ); + ]; $actual = $config_factory ->get('config_translation_test.content') ->getOriginal('content', FALSE); @@ -970,20 +970,20 @@ public function testTextFormatTranslation() { $this->assertNoFieldByName('translation[config_names][config_translation_test.content][content][format]'); // Update translatable fields. - $edit = array( + $edit = [ 'translation[config_names][config_translation_test.content][content][value]' => 'Hello World - FR
', - ); + ]; // Save language specific version of form. $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); // Get translation and check we've got the right value. - $expected = array( + $expected = [ 'value' => 'Hello World - FR
', 'format' => 'plain_text', - ); + ]; $this->container->get('language.config_factory_override') - ->setLanguage(new Language(array('id' => 'fr'))); + ->setLanguage(new Language(['id' => 'fr'])); $actual = $config_factory ->get('config_translation_test.content') ->get('content'); @@ -1009,7 +1009,7 @@ public function testTextFormatTranslation() { $this->drupalLogin($this->translatorUser); $this->drupalGet($translation_page_url); $this->assertDisabledTextarea('edit-translation-config-names-config-translation-testcontent-content-value'); - $this->drupalPostForm(NULL, array(), t('Save translation')); + $this->drupalPostForm(NULL, [], t('Save translation')); // Check that submitting the form did not update the text format of the // translation. $actual = $config_factory @@ -1019,14 +1019,14 @@ public function testTextFormatTranslation() { // The administrator must explicitly change the text format. $this->drupalLogin($this->adminUser); - $edit = array( + $edit = [ 'translation[config_names][config_translation_test.content][content][format]' => 'full_html', - ); + ]; $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); - $expected = array( + $expected = [ 'value' => 'Hello World - FR
', 'format' => 'full_html', - ); + ]; $actual = $config_factory ->get('config_translation_test.content') ->get('content'); @@ -1047,20 +1047,20 @@ public function testTextFormatTranslation() { * Returns translation if exists, FALSE otherwise. */ protected function getTranslation($config_name, $key, $langcode) { - $settings_locations = $this->localeStorage->getLocations(array('type' => 'configuration', 'name' => $config_name)); - $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', array('%config_name' => $config_name))); + $settings_locations = $this->localeStorage->getLocations(['type' => 'configuration', 'name' => $config_name]); + $this->assertTrue(!empty($settings_locations), format_string('Configuration locations found for %config_name.', ['%config_name' => $config_name])); if (!empty($settings_locations)) { $source = $this->container->get('config.factory')->get($config_name)->get($key); - $source_string = $this->localeStorage->findString(array('source' => $source, 'type' => 'configuration')); - $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', array('%config_name' => $config_name, '%key' => $key))); + $source_string = $this->localeStorage->findString(['source' => $source, 'type' => 'configuration']); + $this->assertTrue(!empty($source_string), format_string('Found string for %config_name.%key.', ['%config_name' => $config_name, '%key' => $key])); if (!empty($source_string)) { - $conditions = array( + $conditions = [ 'lid' => $source_string->lid, 'language' => $langcode, - ); - $translations = $this->localeStorage->getTranslations($conditions + array('translated' => TRUE)); + ]; + $translations = $this->localeStorage->getTranslations($conditions + ['translated' => TRUE]); return reset($translations); } } @@ -1074,10 +1074,10 @@ protected function getTranslation($config_name, $key, $langcode) { * @param string $site_slogan */ protected function setSiteInformation($site_name, $site_slogan) { - $edit = array( + $edit = [ 'site_name' => $site_name, 'site_slogan' => $site_slogan, - ); + ]; $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); $this->assertRaw(t('The configuration options have been saved.')); } @@ -1094,11 +1094,11 @@ protected function setSiteInformation($site_name, $site_slogan) { * The response body. */ protected function renderContextualLinks($ids, $current_path) { - $post = array(); + $post = []; for ($i = 0; $i < count($ids); $i++) { $post['ids[' . $i . ']'] = $ids[$i]; } - return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path))); + return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]); } /** @@ -1111,30 +1111,30 @@ protected function renderContextualLinks($ids, $current_path) { * TRUE if the assertion passed; FALSE otherwise. */ protected function assertDisabledTextarea($id) { - $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', array( + $textarea = $this->xpath('//textarea[@id=:id and contains(@disabled, "disabled")]', [ ':id' => $id, - )); + ]); $textarea = reset($textarea); - $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', array( + $passed = $this->assertTrue($textarea instanceof \SimpleXMLElement, SafeMarkup::format('Disabled field @id exists.', [ '@id' => $id, - ))); + ])); $expected = 'This field has been disabled because you do not have sufficient permissions to edit it.'; - $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', array( + $passed = $passed && $this->assertEqual((string) $textarea, $expected, SafeMarkup::format('Disabled textarea @id hides text in an inaccessible text format.', [ '@id' => $id, - ))); + ])); // Make sure the text format select is not shown. $select_id = str_replace('value', 'format--2', $id); - $select = $this->xpath('//select[@id=:id]', array(':id' => $select_id)); - return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', array( + $select = $this->xpath('//select[@id=:id]', [':id' => $select_id]); + return $passed && $this->assertFalse($select, SafeMarkup::format('Field @id does not exist.', [ '@id' => $id, - ))); + ])); } /** * Helper function that returns a .po file with a given number of plural forms. */ public function getPoFile($plurals) { - $po_file = array(); + $po_file = []; $po_file[1] = <<< EOF msgid "" diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php index ab51a43..53713a9 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiThemeTest.php @@ -24,7 +24,7 @@ class ConfigTranslationUiThemeTest extends WebTestBase { * * @var array */ - protected $langcodes = array('fr', 'ta'); + protected $langcodes = ['fr', 'ta']; /** * Administrator user for tests. diff --git a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module index eb41793..8c00b90 100644 --- a/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module +++ b/core/modules/config_translation/tests/modules/config_translation_test/config_translation_test.module @@ -33,7 +33,7 @@ function config_translation_test_entity_type_alter(array &$entity_types) { function config_translation_test_config_translation_info_alter(&$info) { if (\Drupal::state()->get('config_translation_test_config_translation_info_alter')) { // Limit account settings config files to only one of them. - $info['entity.user.admin_form']['names'] = array('user.settings'); + $info['entity.user.admin_form']['names'] = ['user.settings']; // Add one more config file to the site information page. $info['system.site_information_settings']['names'][] = 'system.rss'; diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php index 9ddbdf3..95af49e 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationDateFormatUiTest.php @@ -12,11 +12,11 @@ */ class ConfigTranslationDateFormatUiTest extends BrowserTestBase { - public static $modules = array( + public static $modules = [ 'language', 'config_translation', 'system' - ); + ]; protected function setUp() { parent::setUp(); @@ -27,10 +27,10 @@ protected function setUp() { ConfigurableLanguage::createFromLangcode($langcode)->save(); } - $user = $this->drupalCreateUser(array( + $user = $this->drupalCreateUser([ 'administer site configuration', 'translate configuration', - )); + ]); $this->drupalLogin($user); } diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php index db4af56..586d197 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationListUiTest.php @@ -26,7 +26,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase { * * @var array */ - public static $modules = array( + public static $modules = [ 'block', 'config_translation', 'contact', @@ -40,7 +40,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase { 'image', 'responsive_image', 'toolbar', - ); + ]; /** * Admin user with all needed permissions. @@ -52,7 +52,7 @@ class ConfigTranslationListUiTest extends BrowserTestBase { protected function setUp() { parent::setUp(); - $permissions = array( + $permissions = [ 'access site-wide contact form', 'administer blocks', 'administer contact forms', @@ -70,7 +70,7 @@ protected function setUp() { 'administer image styles', 'administer responsive images', 'translate configuration', - ); + ]; // Create and log in user. $this->adminUser = $this->drupalCreateUser($permissions); @@ -94,7 +94,7 @@ protected function doBlockListTest() { // Add a test block, any block will do. // Set the machine name so the translate link can be built later. $id = Unicode::strtolower($this->randomMachineName(16)); - $this->drupalPlaceBlock('system_powered_by_block', array('id' => $id)); + $this->drupalPlaceBlock('system_powered_by_block', ['id' => $id]); // Get the Block listing. $this->drupalGet('admin/structure/block'); @@ -118,11 +118,11 @@ protected function doMenuListTest() { // Lowercase the machine name. $menu_name = Unicode::strtolower($this->randomMachineName(16)); $label = $this->randomMachineName(16); - $edit = array( + $edit = [ 'id' => $menu_name, 'description' => '', 'label' => $label, - ); + ]; // Create the menu by posting the form. $this->drupalPostForm('admin/structure/menu/add', $edit, t('Save')); @@ -135,9 +135,9 @@ protected function doMenuListTest() { // Check if the Link is not added if you are missing 'translate // configuration' permission. - $permissions = array( + $permissions = [ 'administer menu', - ); + ]; $this->drupalLogin($this->drupalCreateUser($permissions)); // Get the Menu listing. @@ -186,11 +186,11 @@ protected function doVocabularyListTest() { public function doCustomContentTypeListTest() { // Create a test custom block type to decouple looking for translate // operations link so this does not test more than necessary. - $block_content_type = BlockContentType::create(array( + $block_content_type = BlockContentType::create([ 'id' => Unicode::strtolower($this->randomMachineName(16)), 'label' => $this->randomMachineName(), 'revision' => FALSE - )); + ]); $block_content_type->save(); // Get the custom block type listing. @@ -235,10 +235,10 @@ public function doContactFormsListTest() { public function doContentTypeListTest() { // Create a test content type to decouple looking for translate operations // link so this does not test more than necessary. - $content_type = $this->drupalCreateContentType(array( + $content_type = $this->drupalCreateContentType([ 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), - )); + ]); // Get the content type listing. $this->drupalGet('admin/structure/types'); @@ -258,10 +258,10 @@ public function doContentTypeListTest() { public function doFormatsListTest() { // Create a test format to decouple looking for translate operations // link so this does not test more than necessary. - $filter_format = FilterFormat::create(array( + $filter_format = FilterFormat::create([ 'format' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), - )); + ]); $filter_format->save(); // Get the format listing. @@ -282,10 +282,10 @@ public function doFormatsListTest() { public function doShortcutListTest() { // Create a test shortcut to decouple looking for translate operations // link so this does not test more than necessary. - $shortcut = ShortcutSet::create(array( + $shortcut = ShortcutSet::create([ 'id' => Unicode::strtolower($this->randomMachineName(16)), 'label' => $this->randomString(), - )); + ]); $shortcut->save(); // Get the shortcut listing. @@ -307,7 +307,7 @@ public function doUserRoleListTest() { // Create a test role to decouple looking for translate operations // link so this does not test more than necessary. $role_id = Unicode::strtolower($this->randomMachineName(16)); - $this->drupalCreateRole(array(), $role_id); + $this->drupalCreateRole([], $role_id); // Get the role listing. $this->drupalGet('admin/people/roles'); @@ -361,13 +361,13 @@ public function doImageStyleListTest() { * Tests the responsive image mapping listing for the translate operation. */ public function doResponsiveImageListTest() { - $edit = array(); + $edit = []; $edit['label'] = $this->randomMachineName(); $edit['id'] = strtolower($edit['label']); $edit['fallback_image_style'] = 'thumbnail'; $this->drupalPostForm('admin/config/media/responsive-image-style/add', $edit, t('Save')); - $this->assertRaw(t('Responsive image style %label saved.', array('%label' => $edit['label']))); + $this->assertRaw(t('Responsive image style %label saved.', ['%label' => $edit['label']])); // Get the responsive image style listing. $this->drupalGet('admin/config/media/responsive-image-style'); @@ -386,17 +386,17 @@ public function doResponsiveImageListTest() { */ public function doFieldListTest() { // Create a base content type. - $content_type = $this->drupalCreateContentType(array( + $content_type = $this->drupalCreateContentType([ 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), - )); + ]); // Create a block content type. - $block_content_type = BlockContentType::create(array( + $block_content_type = BlockContentType::create([ 'id' => 'basic', 'label' => 'Basic', 'revision' => FALSE - )); + ]); $block_content_type->save(); $field = FieldConfig::create([ // The field storage is guaranteed to exist because it is supplied by the @@ -404,21 +404,21 @@ public function doFieldListTest() { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_content_type->id(), 'label' => 'Body', - 'settings' => array('display_summary' => FALSE), + 'settings' => ['display_summary' => FALSE], ]); $field->save(); // Look at a few fields on a few entity types. - $pages = array( - array( + $pages = [ + [ 'list' => 'admin/structure/types/manage/' . $content_type->id() . '/fields', 'field' => 'node.' . $content_type->id() . '.body', - ), - array( + ], + [ 'list' => 'admin/structure/block/block-content/manage/basic/fields', 'field' => 'block_content.basic.body', - ), - ); + ], + ]; foreach ($pages as $values) { // Get fields listing. diff --git a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php index 9a9aee3..066dcd5 100644 --- a/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php +++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php @@ -16,22 +16,22 @@ class ConfigTranslationViewListUiTest extends UITestBase { * * @var array */ - public static $testViews = array('node', 'test_view'); + public static $testViews = ['node', 'test_view']; /** * Modules to enable. * * @var array */ - public static $modules = array('config_translation', 'views_ui'); + public static $modules = ['config_translation', 'views_ui']; protected function setUp() { parent::setUp(); - $permissions = array( + $permissions = [ 'administer views', 'translate configuration', - ); + ]; // Create and log in user. $this->drupalLogin($this->drupalCreateUser($permissions)); diff --git a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php index dc56e8d..11e72c2 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigEntityMapperTest.php @@ -62,14 +62,14 @@ protected function setUp() { ->with('entity.configurable_language.edit_form') ->will($this->returnValue(new Route('/admin/config/regional/language/edit/{configurable_language}'))); - $definition = array( + $definition = [ 'class' => '\Drupal\config_translation\ConfigEntityMapper', 'base_route_name' => 'entity.configurable_language.edit_form', 'title' => '@label language', - 'names' => array(), + 'names' => [], 'entity_type' => 'configurable_language', 'route_name' => 'config_translation.item.overview.entity.configurable_language.edit_form', - ); + ]; $typed_config_manager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); @@ -152,7 +152,7 @@ public function testGetOverviewRouteParameters() { $result = $this->configEntityMapper->getOverviewRouteParameters(); - $this->assertSame(array('configurable_language' => 'entity_id'), $result); + $this->assertSame(['configurable_language' => 'entity_id'], $result); } /** @@ -205,12 +205,12 @@ public function testGetTypeLabel() { public function testGetOperations() { $result = $this->configEntityMapper->getOperations(); - $expected = array( - 'list' => array( + $expected = [ + 'list' => [ 'title' => 'List', 'url' => Url::fromRoute('config_translation.entity_list', ['mapper_id' => 'configurable_language']), - ), - ); + ], + ]; $this->assertEquals($expected, $result); } diff --git a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php index 204d84e..8e6d0b9 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigFieldMapperTest.php @@ -42,13 +42,13 @@ protected function setUp() { $this->entityManager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); $this->entity = $this->getMock('Drupal\field\FieldConfigInterface'); - $definition = array( + $definition = [ 'class' => '\Drupal\config_translation\ConfigFieldMapper', 'base_route_name' => 'entity.field_config.node_field_edit_form', 'title' => '@label field', - 'names' => array(), + 'names' => [], 'entity_type' => 'field_config', - ); + ]; $locale_config_manager = $this->getMockBuilder('Drupal\locale\LocaleConfigManager') ->disableOriginalConstructor() diff --git a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php index 10bbf7d..9f064ac 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigMapperManagerTest.php @@ -31,7 +31,7 @@ class ConfigMapperManagerTest extends UnitTestCase { protected $typedConfigManager; protected function setUp() { - $language = new Language(array('id' => 'en')); + $language = new Language(['id' => 'en']); $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) ->method('getCurrentLanguage') @@ -83,50 +83,50 @@ public function testHasTranslatable(TypedDataInterface $element, $expected) { * ConfigMapperManager::hasTranslatable() as the second key. */ public function providerTestHasTranslatable() { - return array( - array($this->getElement(array()), FALSE), - array($this->getElement(array('aaa' => 'bbb')), FALSE), - array($this->getElement(array('translatable' => FALSE)), FALSE), - array($this->getElement(array('translatable' => TRUE)), TRUE), - array($this->getNestedElement(array( - $this->getElement(array()), - )), FALSE), - array($this->getNestedElement(array( - $this->getElement(array('translatable' => TRUE)), - )), TRUE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('eee' => 'fff')), - )), FALSE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('translatable' => TRUE)), - )), TRUE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getNestedElement(array( - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('eee' => 'fff')), - )), - $this->getNestedElement(array( - $this->getElement(array('ggg' => 'hhh')), - $this->getElement(array('iii' => 'jjj')), - )), - )), FALSE), - array($this->getNestedElement(array( - $this->getElement(array('aaa' => 'bbb')), - $this->getNestedElement(array( - $this->getElement(array('ccc' => 'ddd')), - $this->getElement(array('eee' => 'fff')), - )), - $this->getNestedElement(array( - $this->getElement(array('ggg' => 'hhh')), - $this->getElement(array('translatable' => TRUE)), - )), - )), TRUE), - ); + return [ + [$this->getElement([]), FALSE], + [$this->getElement(['aaa' => 'bbb']), FALSE], + [$this->getElement(['translatable' => FALSE]), FALSE], + [$this->getElement(['translatable' => TRUE]), TRUE], + [$this->getNestedElement([ + $this->getElement([]), + ]), FALSE], + [$this->getNestedElement([ + $this->getElement(['translatable' => TRUE]), + ]), TRUE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['eee' => 'fff']), + ]), FALSE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['translatable' => TRUE]), + ]), TRUE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getNestedElement([ + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['eee' => 'fff']), + ]), + $this->getNestedElement([ + $this->getElement(['ggg' => 'hhh']), + $this->getElement(['iii' => 'jjj']), + ]), + ]), FALSE], + [$this->getNestedElement([ + $this->getElement(['aaa' => 'bbb']), + $this->getNestedElement([ + $this->getElement(['ccc' => 'ddd']), + $this->getElement(['eee' => 'fff']), + ]), + $this->getNestedElement([ + $this->getElement(['ggg' => 'hhh']), + $this->getElement(['translatable' => TRUE]), + ]), + ]), TRUE], + ]; } /** diff --git a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php index cbf42c8..e7a0679 100644 --- a/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php +++ b/core/modules/config_translation/tests/src/Unit/ConfigNamesMapperTest.php @@ -91,13 +91,13 @@ class ConfigNamesMapperTest extends UnitTestCase { protected function setUp() { $this->routeProvider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface'); - $this->pluginDefinition = array( + $this->pluginDefinition = [ 'class' => '\Drupal\config_translation\ConfigNamesMapper', 'base_route_name' => 'system.site_information_settings', 'title' => 'System information', - 'names' => array('system.site'), + 'names' => ['system.site'], 'weight' => 42, - ); + ]; $this->typedConfigManager = $this->getMock('Drupal\Core\Config\TypedConfigManagerInterface'); @@ -156,7 +156,7 @@ public function testGetBaseRouteName() { */ public function testGetBaseRouteParameters() { $result = $this->configNamesMapper->getBaseRouteParameters(); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -193,7 +193,7 @@ public function testGetOverviewRouteName() { */ public function testGetOverviewRouteParameters() { $result = $this->configNamesMapper->getOverviewRouteParameters(); - $this->assertSame(array(), $result); + $this->assertSame([], $result); } /** @@ -201,13 +201,13 @@ public function testGetOverviewRouteParameters() { */ public function testGetOverviewRoute() { $expected = new Route('/admin/config/system/site-information/translate', - array( + [ '_controller' => '\Drupal\config_translation\Controller\ConfigTranslationController::itemPage', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_overview_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getOverviewRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -242,7 +242,7 @@ public function testGetAddRouteParameters() { $route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']); $this->configNamesMapper->populateFromRouteMatch($route_match); - $expected = array('langcode' => 'xx'); + $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getAddRouteParameters(); $this->assertSame($expected, $result); } @@ -252,13 +252,13 @@ public function testGetAddRouteParameters() { */ public function testGetAddRoute() { $expected = new Route('/admin/config/system/site-information/translate/{langcode}/add', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationAddForm', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_form_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getAddRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -280,7 +280,7 @@ public function testGetEditRouteParameters() { $route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']); $this->configNamesMapper->populateFromRouteMatch($route_match); - $expected = array('langcode' => 'xx'); + $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getEditRouteParameters(); $this->assertSame($expected, $result); } @@ -290,13 +290,13 @@ public function testGetEditRouteParameters() { */ public function testGetEditRoute() { $expected = new Route('/admin/config/system/site-information/translate/{langcode}/edit', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationEditForm', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_form_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getEditRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -318,7 +318,7 @@ public function testGetDeleteRouteParameters() { $route_match = new RouteMatch('example', new Route('/test/{langcode}'), ['langcode' => 'xx']); $this->configNamesMapper->populateFromRouteMatch($route_match); - $expected = array('langcode' => 'xx'); $result = $this->configNamesMapper->getDeleteRouteParameters(); + $expected = ['langcode' => 'xx']; $result = $this->configNamesMapper->getDeleteRouteParameters(); $this->assertSame($expected, $result); } @@ -327,13 +327,13 @@ public function testGetDeleteRouteParameters() { */ public function testGetDeleteRoute() { $expected = new Route('/admin/config/system/site-information/translate/{langcode}/delete', - array( + [ '_form' => '\Drupal\config_translation\Form\ConfigTranslationDeleteForm', 'plugin_id' => 'system.site_information_settings', - ), - array( + ], + [ '_config_translation_form_access' => 'TRUE', - ) + ] ); $result = $this->configNamesMapper->getDeleteRoute(); $this->assertSame(serialize($expected), serialize($result)); @@ -403,38 +403,38 @@ public function testGetTypeLabel() { public function testGetLangcode() { // Test that the getLangcode() falls back to 'en', if no explicit language // code is provided. - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('key' => 'value'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['key' => 'value'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); $result = $this->configNamesMapper->getLangcode(); $this->assertSame('en', $result); // Test that getLangcode picks up the language code provided by the // configuration. - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('langcode' => 'xx'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['langcode' => 'xx'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); $result = $this->configNamesMapper->getLangcode(); $this->assertSame('xx', $result); // Test that getLangcode() works for multiple configuration names. $this->configNamesMapper->addConfigName('system.maintenance'); - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('langcode' => 'xx'), - 'system.maintenance' => array('langcode' => 'xx'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['langcode' => 'xx'], + 'system.maintenance' => ['langcode' => 'xx'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); $result = $this->configNamesMapper->getLangcode(); $this->assertSame('xx', $result); // Test that getLangcode() throws an exception when different language codes // are given. - $config_factory = $this->getConfigFactoryStub(array( - 'system.site' => array('langcode' => 'xx'), - 'system.maintenance' => array('langcode' => 'yy'), - )); + $config_factory = $this->getConfigFactoryStub([ + 'system.site' => ['langcode' => 'xx'], + 'system.maintenance' => ['langcode' => 'yy'], + ]); $this->configNamesMapper->setConfigFactory($config_factory); try { $this->configNamesMapper->getLangcode(); @@ -448,22 +448,22 @@ public function testGetLangcode() { * Tests ConfigNamesMapper::getConfigData(). */ public function testGetConfigData() { - $configs = array( - 'system.site' => array( + $configs = [ + 'system.site' => [ 'name' => 'Drupal', 'slogan' => 'Come for the software, stay for the community!', - ), - 'system.maintenance' => array( + ], + 'system.maintenance' => [ 'enabled' => FALSE, 'message' => '@site is currently under maintenance.', - ), - 'system.rss' => array( - 'items' => array( + ], + 'system.rss' => [ + 'items' => [ 'limit' => 10, 'view_mode' => 'rss', - ), - ), - ); + ], + ], + ]; $this->configNamesMapper->setConfigNames(array_keys($configs)); $config_factory = $this->getConfigFactoryStub($configs); @@ -489,9 +489,9 @@ public function testHasSchema(array $mock_return_values, $expected) { $config_names = range(1, count($mock_return_values)); $this->configNamesMapper->setConfigNames($config_names); - $map = array(); + $map = []; foreach ($config_names as $i => $config_name) { - $map[] = array($config_name, $mock_return_values[$i]); + $map[] = [$config_name, $mock_return_values[$i]]; } $this->typedConfigManager ->expects($this->any()) @@ -512,12 +512,12 @@ public function testHasSchema(array $mock_return_values, $expected) { * ConfigNamesMapper::hasSchema() as the second value. */ public function providerTestHasSchema() { - return array( - array(array(TRUE), TRUE), - array(array(FALSE), FALSE), - array(array(TRUE, TRUE, TRUE), TRUE), - array(array(TRUE, FALSE, TRUE), FALSE), - ); + return [ + [[TRUE], TRUE], + [[FALSE], FALSE], + [[TRUE, TRUE, TRUE], TRUE], + [[TRUE, FALSE, TRUE], FALSE], + ]; } /** @@ -536,9 +536,9 @@ public function testHasTranslatable(array $mock_return_values, $expected) { $config_names = range(1, count($mock_return_values)); $this->configNamesMapper->setConfigNames($config_names); - $map = array(); + $map = []; foreach ($config_names as $i => $config_name) { - $map[] = isset($mock_return_values[$i]) ? array($config_name, $mock_return_values[$i]) : array(); + $map[] = isset($mock_return_values[$i]) ? [$config_name, $mock_return_values[$i]] : []; } $this->configMapperManager ->expects($this->any()) @@ -559,14 +559,14 @@ public function testHasTranslatable(array $mock_return_values, $expected) { * ConfigNamesMapper::hasTranslatable() as the second value. */ public function providerTestHasTranslatable() { - return array( - array(array(), FALSE), - array(array(TRUE), TRUE), - array(array(FALSE), FALSE), - array(array(TRUE, TRUE, TRUE), TRUE), - array(array(FALSE, FALSE, FALSE), FALSE), - array(array(TRUE, FALSE, TRUE), TRUE), - ); + return [ + [[], FALSE], + [[TRUE], TRUE], + [[FALSE], FALSE], + [[TRUE, TRUE, TRUE], TRUE], + [[FALSE, FALSE, FALSE], FALSE], + [[TRUE, FALSE, TRUE], TRUE], + ]; } /** @@ -587,9 +587,9 @@ public function testHasTranslation(array $mock_return_values, $expected) { $config_names = range(1, count($mock_return_values)); $this->configNamesMapper->setConfigNames($config_names); - $map = array(); + $map = []; foreach ($config_names as $i => $config_name) { - $map[] = array($config_name, $language->getId(), $mock_return_values[$i]); + $map[] = [$config_name, $language->getId(), $mock_return_values[$i]]; } $this->localeConfigManager ->expects($this->any()) @@ -610,13 +610,13 @@ public function testHasTranslation(array $mock_return_values, $expected) { * ConfigNamesMapper::hasTranslation() as the second value. */ public function providerTestHasTranslation() { - return array( - array(array(TRUE), TRUE), - array(array(FALSE), FALSE), - array(array(TRUE, TRUE, TRUE), TRUE), - array(array(FALSE, FALSE, TRUE), TRUE), - array(array(FALSE, FALSE, FALSE), FALSE), - ); + return [ + [[TRUE], TRUE], + [[FALSE], FALSE], + [[TRUE, TRUE, TRUE], TRUE], + [[FALSE, FALSE, TRUE], TRUE], + [[FALSE, FALSE, FALSE], FALSE], + ]; } /** @@ -631,12 +631,12 @@ public function testGetTypeName() { * Tests ConfigNamesMapper::hasTranslation(). */ public function testGetOperations() { - $expected = array( - 'translate' => array( + $expected = [ + 'translate' => [ 'title' => 'Translate', 'url' => Url::fromRoute('config_translation.item.overview.system.site_information_settings'), - ), - ); + ], + ]; $result = $this->configNamesMapper->getOperations(); $this->assertEquals($expected, $result); } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 4306e3b..65e7592 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -21,17 +21,17 @@ function contact_help($route_name, RouteMatchInterface $route_match) { $contact_page = \Drupal::url('entity.contact_form.collection'); $output = ''; $output .= '' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the online documentation for the Contact module.', array(':contact' => 'https://www.drupal.org/documentation/modules/contact')) . '
'; + $output .= '' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the online documentation for the Contact module.', [':contact' => 'https://www.drupal.org/documentation/modules/contact']) . '
'; $output .= '