diff --git a/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module index 3c28ef0..209d766 100644 --- a/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -83,10 +83,10 @@ 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( + 'settings' => [ 'display_summary' => FALSE, - 'allowed_formats' => array(), - ), + 'allowed_formats' => [], + ], )); $field->save(); diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index dc7e344..1aa9735 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -403,10 +403,10 @@ public function doFieldListTest() { 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_content_type->id(), 'label' => 'Body', - 'settings' => array( + 'settings' => [ 'display_summary' => FALSE, - 'allowed_formats' => array(), - ), + 'allowed_formats' => [], + ], )); $field->save(); diff --git a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php index 379cea5..7da44ff 100644 --- a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php +++ b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php @@ -78,10 +78,10 @@ public function testFieldInstanceSettings() { // Test a text field. $field = FieldConfig::load('node.story.field_test'); $this->assertIdentical('Text Field', $field->label()); - $expected = array( - 'allowed_formats' => array(), + $expected = [ 'max_length' => 255, - ); + 'allowed_formats' => [], + ]; $this->assertIdentical($expected, $field->getSettings()); $this->assertIdentical('text for default value', $entity->field_test->value); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index d2128ed..338daed 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -328,10 +328,10 @@ function node_add_body_field(NodeTypeInterface $type, $label = 'Body') { 'field_storage' => $field_storage, 'bundle' => $type->id(), 'label' => $label, - 'settings' => array( + 'settings' => [ 'display_summary' => TRUE, - 'allowed_formats' => array(), - ), + 'allowed_formats' => [], + ], )); $field->save(); diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php index bc826d7..e19cc48 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php @@ -24,21 +24,19 @@ * {@inheritdoc} */ public static function defaultFieldSettings() { - return array( - 'allowed_formats' => array(), - ) + parent::defaultFieldSettings(); + return ['allowed_formats' => []] + parent::defaultFieldSettings(); } public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $element = parent::fieldSettingsForm($form, $form_state); $settings = $this->getSettings(); - $element['allowed_formats'] = array( + $element['allowed_formats'] = [ '#type' => 'checkboxes', '#title' => t('Allowed text formats'), '#options' => $this->getProperties()['format']->getPossibleOptions(), '#default_value' => $settings['allowed_formats'], - ); + ]; return $element; } diff --git a/core/modules/text/src/Tests/TextFieldTest.php b/core/modules/text/src/Tests/TextFieldTest.php index 8b303da..6b2913f 100644 --- a/core/modules/text/src/Tests/TextFieldTest.php +++ b/core/modules/text/src/Tests/TextFieldTest.php @@ -90,19 +90,19 @@ function testTextfieldWidgetsAllowedFormats() { // Create one text format. $this->drupalLogin($this->adminUser); - $edit = array( + $edit = [ 'format' => Unicode::strtolower($this->randomMachineName()), 'name' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration')); filter_formats_reset(); $format1 = entity_load('filter_format', $edit['format']); // Create a second text format. - $edit = array( + $edit = [ 'format' => Unicode::strtolower($this->randomMachineName()), 'name' => $this->randomMachineName(), - ); + ]; $this->drupalPostForm('admin/config/content/formats/add', $edit, t('Save configuration')); filter_formats_reset(); $format2 = entity_load('filter_format', $edit['format']); @@ -110,30 +110,30 @@ function testTextfieldWidgetsAllowedFormats() { // Grant access to both formats to the user. $roles = $this->webUser->getRoles(); $rid = $roles[0]; - user_role_grant_permissions($rid, array( + user_role_grant_permissions($rid, [ $format1->getPermissionName(), $format2->getPermissionName(), - )); + ]); // Create a field with multiple formats allowed. $field_name = Unicode::strtolower($this->randomMachineName()); - $field_storage = entity_create('field_storage_config', array( + $field_storage = entity_create('field_storage_config', [ 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'text', - )); + ]); $field_storage->save(); - $field = entity_create('field_config', array( + $field = entity_create('field_config', [ 'field_storage' => $field_storage, 'bundle' => 'entity_test', 'label' => $this->randomMachineName() . '_label', - 'settings' => array('allowed_formats' => array($format1->id(), $format2->id())), - )); + 'settings' => ['allowed_formats' => [$format1->id(), $format2->id()]], + ]); $field->save(); entity_get_form_display('entity_test', 'entity_test', 'default') - ->setComponent($field_name, array( + ->setComponent($field_name, [ 'type' => 'text_textfield', - )) + ]) ->save(); entity_get_display('entity_test', 'entity_test', 'full') ->setComponent($field_name) @@ -146,7 +146,7 @@ function testTextfieldWidgetsAllowedFormats() { $this->assertFieldByName("{$field_name}[0][format]", NULL, 'Format selector is displayed'); // Change field to allow only one format. - $field->setSetting('allowed_formats', array($format1->id())); + $field->setSetting('allowed_formats', [$format1->id()]); $field->save(); // We shouldn't have the 'format' selector since only one format is allowed. $this->drupalGet('entity_test/add'); diff --git a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php index a83a1ac..ad8b5cb 100644 --- a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php +++ b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php @@ -76,10 +76,10 @@ protected function setUp() { 'field_storage' => FieldStorageConfig::loadByName('node', 'body'), 'bundle' => $content_type->id(), 'label' => $this->randomMachineName() . '_body', - 'settings' => array( + 'settings' => [ 'display_summary' => TRUE, - 'allowed_formats' => array(), - ), + 'allowed_formats' => [], + ], ))->save(); ViewTestData::createTestViews(get_class($this), array('views_test_config'));