commit 3f6181bc65ea21a7086c4739ceae661a87816d40 Author: Lee Rowlands Date: Sat Apr 26 22:53:51 2014 +1000 Patch 5 diff --git a/core/lib/Drupal/Core/Field/FieldItemBase.php b/core/lib/Drupal/Core/Field/FieldItemBase.php index 33ec95c..39b9412 100644 --- a/core/lib/Drupal/Core/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Field/FieldItemBase.php @@ -243,7 +243,7 @@ public function deleteRevision() { } /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { return array(); } diff --git a/core/lib/Drupal/Core/Field/FieldItemInterface.php b/core/lib/Drupal/Core/Field/FieldItemInterface.php index d10790d..22da92d 100644 --- a/core/lib/Drupal/Core/Field/FieldItemInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemInterface.php @@ -250,7 +250,7 @@ public static function defaultInstanceSettings(); * @return * The form definition for the field settings. */ - public function settingsForm(array $form, array &$form_state, $has_data); + public function settingsForm(array &$form, array &$form_state, $has_data); /** * Returns a form for the instance-level settings. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php index 30d33c5..10d03b3 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/DecimalItem.php @@ -63,7 +63,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element = array(); $settings = $this->getSettings(); diff --git a/core/modules/comment/comment.menu_links.yml b/core/modules/comment/comment.menu_links.yml index 740de41..8b582de 100644 --- a/core/modules/comment/comment.menu_links.yml +++ b/core/modules/comment/comment.menu_links.yml @@ -4,7 +4,7 @@ comment.admin: parent: system.admin description: 'List and edit site comments and the comment approval queue.' comment.type_list: - title: 'Comment forms' + title: 'Comment types' route_name: comment.type_list parent: system.admin_structure description: 'Manage fields and displays settings for comment forms.' diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 525e46b..f8cb756 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -184,15 +184,6 @@ function comment_count_unpublished() { } /** - * Implements hook_ENTITY_TYPE_insert() for 'field_instance_config'. - */ -function comment_field_instance_config_insert(FieldInstanceConfigInterface $instance) { - if ($instance->getType() == 'comment' && !$instance->isSyncing()) { - \Drupal::service('comment.manager')->addBodyField($instance->getSetting('comment_type')); - } -} - -/** * Implements hook_ENTITY_TYPE_create() for 'field_instance_config'. */ function comment_field_instance_config_create(FieldInstanceConfigInterface $instance) { diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index 89680ef..ae636e3 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -66,12 +66,6 @@ comment.new_comments_node_links: requirements: _permission: 'access content' -# This route is only used by Field UI. -comment.bundle: - path: '/admin/structure/comments/manage/{bundle}' - requirements: - _access: 'FALSE' - comment.node_redirect: path: '/comment/{node}/reply' defaults: @@ -81,7 +75,7 @@ comment.node_redirect: _module_dependencies: 'node' comment.type_list: - path: '/admin/structure/comments' + path: '/admin/structure/comment' defaults: _entity_list: 'comment_type' _title: 'Comment forms' diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index cc957dd..4bf11b7 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -131,7 +131,15 @@ public function getAllFields() { */ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = CommentItemInterface::OPEN, $comment_type_id = 'comment') { $comment_type_storage = $this->entityManager->getStorage('comment_type'); - if (!($comment_type = $comment_type_storage->load($comment_type_id))) { + if ($comment_type = $comment_type_storage->load($comment_type_id)) { + if ($comment_type->targetEntityTypeId !== $entity_type) { + throw new \InvalidArgumentException($this->t('The given comment type id %id can only be used with the %entity_type entity type', array( + '%id' => $comment_type_id, + '%entity_type' => $entity_type, + ))); + } + } + else { $comment_type_storage->create(array( 'id' => $comment_type_id, 'label' => $comment_type_id, @@ -139,12 +147,6 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', 'description' => 'Default comment field', ))->save(); } - else if ($comment_type->targetEntityTypeId !== $entity_type) { - throw new \InvalidArgumentException($this->t('The given comment type id %id can only be used with the %entity_type entity type', array( - '%id' => $comment_type_id, - '%entity_type' => $entity_type, - ))); - } // Make sure the field doesn't already exist. if (!$this->fieldInfo->getField($entity_type, $field_name)) { // Add a default comment field for existing node comments. diff --git a/core/modules/comment/lib/Drupal/comment/CommentTypeFormController.php b/core/modules/comment/lib/Drupal/comment/CommentTypeFormController.php index 295085d..d7ec4f9 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentTypeFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentTypeFormController.php @@ -7,13 +7,13 @@ namespace Drupal\comment; -use Drupal\Core\Entity\EntityFormController; +use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeInterface; /** * Base form controller for category edit forms. */ -class CommentTypeFormController extends EntityFormController { +class CommentTypeFormController extends EntityForm { /** * {@inheritdoc} diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index fb52ec5..944d2fe 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -46,8 +46,9 @@ * "canonical" = "comment.permalink", * "delete-form" = "comment.confirm_delete", * "edit-form" = "comment.edit_page", - * "admin-form" = "comment.bundle" - * } + * "admin-form" = "comment.type_edit" + * }, + * bundle_entity_type = "comment_type" * ) */ class Comment extends ContentEntityBase implements CommentInterface { diff --git a/core/modules/comment/lib/Drupal/comment/Form/CommentTypeDeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/CommentTypeDeleteForm.php index 81a8d83..9775892 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/CommentTypeDeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/CommentTypeDeleteForm.php @@ -103,10 +103,10 @@ public function buildForm(array $form, array &$form_state) { $comments = $this->queryFactory->get('comment')->condition('comment_type', $this->entity->id())->execute(); $entity_type = $this->entity->getTargetEntityTypeId(); $caption = ''; - foreach ($this->commentManager->getFields($entity_type) as $field_name) { + foreach (array_keys($this->commentManager->getFields($entity_type)) as $field_name) { /** @var \Drupal\field\FieldConfigInterface $field */ - if (($field = $this->entityManager->getStorage($entity_type)->load($entity_type . '.' . $field_name)) && $field->getSetting('comment_type') == $this->entity->id()) { - $caption .= '

' . $this->t('%label is used by the %field on your site. You can not remove this comment type until you have removed the field.', array( + if (($field = $this->entityManager->getStorage('field_config')->load($entity_type . '.' . $field_name)) && $field->getSetting('comment_type') == $this->entity->id()) { + $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.', array( '%label' => $this->entity->label(), '%field' => $field->label(), )) . '

'; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php index 3e95617..4113451 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php @@ -195,7 +195,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element = array(); // @todo Inject storage controller once typed-data supports container @@ -214,6 +214,7 @@ public function settingsForm(array $form, array &$form_state, $has_data) { '#options' => $options, '#description' => t('Select the Comment type to use for this comment field.'), '#default_value' => $this->getSetting('comment_type'), + '#disabled' => $has_data, ); $element['new_comment_type'] = array( '#tree' => TRUE, @@ -231,14 +232,17 @@ public function settingsForm(array $form, array &$form_state, $has_data) { '#maxlength' => 255, '#default_value' => '', '#description' => t("Provide a label for the new comment type to help identify it in the administration pages."), - '#required' => TRUE, ); $element['new_comment_type']['id'] = array( '#type' => 'machine_name', '#default_value' => '', '#machine_name' => array( 'exists' => 'comment_type_load', + 'source' => array( + 'field', 'settings', 'new_comment_type', 'label' + ), ), + '#required' => FALSE, '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, ); @@ -252,7 +256,8 @@ public function settingsForm(array $form, array &$form_state, $has_data) { '#type' => 'value', '#value' => $entity_type, ); - array_unshift($form['#submit'], array($this, 'createNewCommentType')); + $form['#submit'][] = array($this, 'createNewCommentType'); + $form['#validate'][] = array($this, 'validateNewCommentType'); return $element; } @@ -269,4 +274,19 @@ public function createNewCommentType($form, &$form_state) { } } + /** + * Validation handler for creating a new comment type if required. + */ + public function validateNewCommentType($form, &$form_state) { + $settings = $form_state['values']['field']['settings']; + if ($settings['comment_type'] == 'new') { + if (empty($settings['new_comment_type']['label'])) { + \Drupal::formBuilder()->setErrorByName('field][settings][new_comment_type][label', $form_state, t('Please provide a label for the new comment type')); + } + if (empty($settings['new_comment_type']['id'])) { + \Drupal::formBuilder()->setErrorByName('field][settings][new_comment_type][id', $form_state, t('Please provide a machine name for the new comment type')); + } + } + } + } diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php index 4f2f211..512262d 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentAdminTest.php @@ -160,8 +160,7 @@ public function testCommentAdmin() { $this->drupalGet('admin/structure/comments'); $this->assertResponse(200); // Make sure titles visible. - $this->assertText('Field name'); - $this->assertText('Used in'); + $this->assertText('Comment type'); $this->assertText('Description'); // Make sure the description is present. $this->assertText('Default comment field'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php index 3aa6eda..f0c5b14 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentFieldsTest.php @@ -40,7 +40,7 @@ function testCommentDefaultFields() { $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type'); // Check that the 'comment_body' field is present on the comment bundle. - $instance = $this->container->get('field.info')->getInstance('comment', 'node__comment', 'comment_body'); + $instance = $this->container->get('field.info')->getInstance('comment', 'comment', 'comment_body'); $this->assertTrue(!empty($instance), 'The comment_body field is added when a comment bundle is created'); $instance->delete(); @@ -59,7 +59,7 @@ function testCommentDefaultFields() { $field = $this->container->get('field.info')->getField('comment', 'comment_body'); $this->assertTrue($field, 'The comment_body field exists'); $instances = $this->container->get('field.info')->getInstances('comment'); - $this->assertTrue(isset($instances['node__comment']['comment_body']), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name))); + $this->assertTrue(isset($instances['comment']['comment_body']), format_string('The comment_body field is present for comments on type @type', array('@type' => $type_name))); // Test adding a field that defaults to CommentItemInterface::CLOSED. $this->container->get('comment.manager')->addDefaultField('node', 'test_node_type', 'who_likes_ponies', CommentItemInterface::CLOSED, 'who_likes_ponies'); @@ -129,10 +129,10 @@ function testCommentFormat() { // Disable text processing for comments. $this->drupalLogin($this->admin_user); $edit = array('instance[settings][text_processing]' => 0); - $this->drupalPostForm('admin/structure/comments/manage/node__comment/fields/comment.node__comment.comment_body', $edit, t('Save settings')); + $this->drupalPostForm('admin/structure/comments/manage/comment/fields/comment.comment.comment_body', $edit, t('Save settings')); // Change formatter settings. - $this->drupalGet('admin/structure/comments/manage/node__comment/display'); + $this->drupalGet('admin/structure/comments/manage/comment/display'); $edit = array('fields[comment_body][type]' => 'text_trimmed', 'refresh_rows' => 'comment_body'); $commands = $this->drupalPostAjaxForm(NULL, $edit, array('op' => t('Refresh'))); $this->assertTrue($commands, 'Ajax commands returned'); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php index d4af65e..882b7b0 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentNonNodeTest.php @@ -358,10 +358,47 @@ function testCommentFunctionality() { 'fields[_add_new_field][type]' => 'comment', ); $this->drupalPostForm(NULL, $edit, t('Save')); - $this->drupalPostForm(NULL, array(), t('Save field settings')); + // Attempt to save with a new comment-type but incomplete form. + $this->drupalPostForm(NULL, array( + 'field[settings][comment_type]' => 'new', + ), t('Save field settings')); + $this->assertText(t('Please provide a label for the new comment type')); + $this->assertText(t('Please provide a machine name for the new comment type')); + // Now provide the required values. + $this->drupalPostForm(NULL, array( + 'field[settings][comment_type]' => 'new', + 'field[settings][new_comment_type][id]' => 'foobar', + 'field[settings][new_comment_type][label]' => 'Foobar', + ), t('Save field settings')); + $this->drupalPostForm(NULL, array(), t('Save settings')); $this->assertRaw(t('Saved %name configuration', array('%name' => 'Foobar'))); + // Check the new comment_type was created. + $comment_type = entity_load('comment_type', 'foobar'); + $this->assertTrue($comment_type); + $this->assertEqual($comment_type->label(), 'Foobar'); + + // Add a third comment field. + $this->drupalGet('entity_test/structure/entity_test/fields'); + $edit = array( + 'fields[_add_new_field][label]' => 'Barfoo', + 'fields[_add_new_field][field_name]' => 'barfoo', + 'fields[_add_new_field][type]' => 'comment', + ); + $this->drupalPostForm(NULL, $edit, t('Save')); + // Re-use another comment type. + $this->drupalPostForm(NULL, array( + 'field[settings][comment_type]' => 'foobar', + ), t('Save field settings')); + $this->drupalPostForm(NULL, array(), t('Save settings')); + $this->assertRaw(t('Saved %name configuration', array('%name' => 'Barfoo'))); + + // Check the field contains the correct comment type. + $field = entity_load('field_config', 'entity_test.field_barfoo'); + $this->assertTrue($field); + $this->assertEqual($field->getSetting('comment_type'), 'foobar'); + // Test the new entity commenting inherits default. $random_label = $this->randomName(); $data = array('bundle' => 'entity_test', 'name' => $random_label); diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php index 1cf9774..1344f51 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTranslationUITest.php @@ -38,7 +38,7 @@ public static function getInfo() { function setUp() { $this->entityTypeId = 'comment'; $this->nodeBundle = 'article'; - $this->bundle = 'node__comment_article'; + $this->bundle = 'comment_article'; $this->testLanguageSelector = FALSE; $this->subject = $this->randomName(); parent::setUp(); @@ -58,7 +58,7 @@ function setupBundle() { // translatable. $this->container->get('comment.manager')->addDefaultField('node', 'page', 'comment'); // Mark this bundle as translatable. - content_translation_set_config('comment', 'node__comment_article', 'enabled', TRUE); + content_translation_set_config('comment', 'comment_article', 'enabled', TRUE); // Refresh entity info. entity_info_cache_clear(); // Flush the permissions after adding the translatable comment bundle. diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentTypeTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentTypeTest.php index 31aa0d4..2542aad 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentTypeTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentTypeTest.php @@ -22,13 +22,6 @@ class CommentTypeTest extends CommentTestBase { protected $adminUser; /** - * Modules to enable. - * - * @var array - */ - public static $modules = array('field_ui'); - - /** * Permissions to grant admin user. * * @var array @@ -59,7 +52,7 @@ public static function getInfo() { /** * Tests creating a comment type programmatically and via a form. - */ + * / public function testCommentTypeCreation() { // Create a comment type programmaticaly. $type = $this->createCommentType('other'); @@ -91,32 +84,32 @@ public function testCommentTypeCreation() { /** * Tests editing a comment type using the UI. - */ + * / public function testCommentTypeEditing() { $this->drupalLogin($this->adminUser); - $this->createCommentType('other'); - $instance = field_info_instance('comment', 'comment_body', 'other'); + $instance = field_info_instance('comment', 'comment_body', 'comment'); $this->assertEqual($instance->getLabel(), 'Comment', 'Comment body field was found.'); // Change the comment type name. + $this->drupalGet('admin/structure/comment'); $edit = array( 'label' => 'Bar', ); - $this->drupalPostForm('admin/structure/comment/manage/other', $edit, t('Save')); + $this->drupalPostForm('admin/structure/comment/manage/comment', $edit, t('Save')); field_info_cache_clear(); $this->drupalGet('admin/structure/comment'); $this->assertRaw('Bar', 'New name was displayed.'); - $this->clickLink('Edit fields'); - $this->assertEqual(url('admin/structure/comment/manage/other/fields', array('absolute' => TRUE)), $this->getUrl(), 'Original machine name was used in URL.'); + $this->clickLink('Manage fields'); + $this->assertEqual(url('admin/structure/comment/manage/comment/fields', array('absolute' => TRUE)), $this->getUrl(), 'Original machine name was used in URL.'); // Remove the body field. - $this->drupalPostForm('admin/structure/comment/manage/other/fields/comment.other.comment_body/delete', array(), t('Delete')); + $this->drupalPostForm('admin/structure/comment/manage/comment/fields/comment.comment.comment_body/delete', array(), t('Delete')); // Resave the settings for this type. - $this->drupalPostForm('admin/structure/comment/manage/other', array(), t('Save')); + $this->drupalPostForm('admin/structure/comment/manage/comment', array(), t('Save')); // Check that the body field doesn't exist. - $this->drupalGet('admin/structure/comment/manage/other/fields'); + $this->drupalGet('admin/structure/comment/manage/comment/fields'); $this->assertNoRaw('comment_body', 'Body field was not found.'); } @@ -126,6 +119,7 @@ public function testCommentTypeEditing() { public function testCommentTypeDeletion() { // Create a comment type programmatically. $type = $this->createCommentType('foo'); + $this->drupalCreateContentType(array('type' => 'page')); \Drupal::service('comment.manager')->addDefaultField('node', 'page', 'foo', CommentItemInterface::OPEN, 'foo'); $field = Field::fieldInfo()->getField('node', 'foo'); @@ -154,9 +148,9 @@ public function testCommentTypeDeletion() { 'The comment type will not be deleted until all comments of that type are removed.' ); $this->assertRaw( - t('%label is used by the %field on your site. You can not remove this comment type until you have removed the field.', array( + 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( '%label' => 'foo', - '%field' => 'foo', + '%field' => 'node.foo', )), 'The comment type will not be deleted until all fields of that type are removed.' ); @@ -166,26 +160,22 @@ public function testCommentTypeDeletion() { $comment->delete(); $field->delete(); // Attempt to delete the comment type, which should now be allowed. - $this->drupalGet('admin/structure/block/custom-blocks/manage/' . $type->id() . '/delete'); + $this->drupalGet('admin/structure/comment/manage/' . $type->id() . '/delete'); $this->assertRaw( t('Are you sure you want to delete %type?', array('%type' => $type->id())), 'The comment type is available for deletion.' ); $this->assertText(t('This action cannot be undone.'), 'The comment type deletion confirmation form is available.'); - } - - /** - * Tests the create new comment type functionality on the CommentItem form. - */ - public function testCreateCommentType() { - $this->fail('You need a test for the new comment-type form on the field instance form'); - } - /** - * Tests that CommentManager::addDefaultField throws expected Exception. - */ - public function testAddDefaultFieldsException() { - $this->fail('You need a test for the Exception thrown'); + // Test exception thrown when re-using an existing comment type. + try { + \Drupal::service('comment.manager')->addDefaultField('comment', 'comment', 'bar'); + } + catch (\InvalidArgumentException $e) { + $this->pass('Exception thrown if attempting to re-use comment-type from another entity type.'); + return; + } + $this->fail('Exception not thrown.'); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php index 241b51f..0c40fe0 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationSettingsTest.php @@ -55,21 +55,21 @@ function testSettingsUI() { $this->assertText('Configure language and translation support for content.'); // Test that the translation settings are ignored if the bundle is marked // translatable but the entity type is not. - $edit = array('settings[comment][node__comment_article][translatable]' => TRUE); + $edit = array('settings[comment][comment_article][translatable]' => TRUE); $this->assertSettings('comment', NULL, FALSE, $edit); // Test that the translation settings are ignored if only a field is marked // as translatable and not the related entity type and bundle. - $edit = array('settings[comment][node__comment_article][fields][comment_body]' => TRUE); + $edit = array('settings[comment][comment_article][fields][comment_body]' => TRUE); $this->assertSettings('comment', NULL, FALSE, $edit); // Test that the translation settings are not stored if an entity type and // bundle are marked as translatable but no field is. $edit = array( 'entity_types[comment]' => TRUE, - 'settings[comment][node__comment_article][translatable]' => TRUE, + 'settings[comment][comment_article][translatable]' => TRUE, ); - $this->assertSettings('comment', 'node__comment_article', FALSE, $edit); + $this->assertSettings('comment', 'comment_article', FALSE, $edit); $xpath_err = '//div[contains(@class, "error")]'; $this->assertTrue($this->xpath($xpath_err), 'Enabling translation only for entity bundles generates a form error.'); @@ -77,35 +77,35 @@ function testSettingsUI() { // language is set as default and the language selector is hidden. $edit = array( 'entity_types[comment]' => TRUE, - 'settings[comment][node__comment_article][settings][language][langcode]' => Language::LANGCODE_NOT_SPECIFIED, - 'settings[comment][node__comment_article][settings][language][language_show]' => FALSE, - 'settings[comment][node__comment_article][translatable]' => TRUE, - 'settings[comment][node__comment_article][fields][comment_body]' => TRUE, + 'settings[comment][comment_article][settings][language][langcode]' => Language::LANGCODE_NOT_SPECIFIED, + 'settings[comment][comment_article][settings][language][language_show]' => FALSE, + 'settings[comment][comment_article][translatable]' => TRUE, + 'settings[comment][comment_article][fields][comment_body]' => TRUE, ); - $this->assertSettings('comment', 'node__comment_article', FALSE, $edit); + $this->assertSettings('comment', 'comment_article', FALSE, $edit); $this->assertTrue($this->xpath($xpath_err), 'Enabling translation with a fixed non-configurable language generates a form error.'); // Test that a field shared among different bundles can be enabled without // needing to make all the related bundles translatable. $edit = array( 'entity_types[comment]' => TRUE, - 'settings[comment][node__comment_article][settings][language][langcode]' => 'current_interface', - 'settings[comment][node__comment_article][settings][language][language_show]' => TRUE, - 'settings[comment][node__comment_article][translatable]' => TRUE, - 'settings[comment][node__comment_article][fields][comment_body]' => TRUE, + 'settings[comment][comment_article][settings][language][langcode]' => 'current_interface', + 'settings[comment][comment_article][settings][language][language_show]' => TRUE, + 'settings[comment][comment_article][translatable]' => TRUE, + 'settings[comment][comment_article][fields][comment_body]' => TRUE, ); - $this->assertSettings('comment', 'node__comment_article', TRUE, $edit); + $this->assertSettings('comment', 'comment_article', TRUE, $edit); field_info_cache_clear(); $field = field_info_field('comment', 'comment_body'); $this->assertTrue($field->isTranslatable(), 'Comment body is translatable.'); // Test that language settings are correctly stored. - $language_configuration = language_get_default_configuration('comment', 'node__comment_article'); + $language_configuration = language_get_default_configuration('comment', 'comment_article'); $this->assertEqual($language_configuration['langcode'], 'current_interface', 'The default language for article comments is set to the current interface language.'); $this->assertTrue($language_configuration['language_show'], 'The language selector for article comments is shown.'); // Verify language widget appears on node type form. - $this->drupalGet('admin/structure/comments/manage/node__comment_article/fields/comment.node__comment_article.comment_body/field'); + $this->drupalGet('admin/structure/comments/manage/comment_article/fields/comment.comment_article.comment_body/field'); $this->assertField('field[translatable]'); $this->assertFieldChecked('edit-field-translatable'); diff --git a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php index d347815..7766dcf 100644 --- a/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php +++ b/core/modules/datetime/lib/Drupal/datetime/Plugin/Field/FieldType/DateTimeItem.php @@ -84,7 +84,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element = array(); $element['datetime_type'] = array( diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php index dc4816d..972731e 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/ConfigurableEntityReferenceItem.php @@ -158,7 +158,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element['target_type'] = array( '#type' => 'select', '#title' => t('Type of item to reference'), diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php index 19f5035..0742a6e 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceSelectionAccessTest.php @@ -454,7 +454,7 @@ public function testCommentHandler() { array(NULL, 'CONTAINS'), ), 'result' => array( - 'node__comment' => array( + 'comment' => array( $comments['published_published']->cid->value => $comment_labels['published_published'], ), ), @@ -464,7 +464,7 @@ public function testCommentHandler() { array('Published', 'CONTAINS'), ), 'result' => array( - 'node__comment' => array( + 'comment' => array( $comments['published_published']->cid->value => $comment_labels['published_published'], ), ), @@ -493,7 +493,7 @@ public function testCommentHandler() { array(NULL, 'CONTAINS'), ), 'result' => array( - 'node__comment' => array( + 'comment' => array( $comments['published_published']->cid->value => $comment_labels['published_published'], $comments['published_unpublished']->cid->value => $comment_labels['published_unpublished'], ), @@ -511,7 +511,7 @@ public function testCommentHandler() { array(NULL, 'CONTAINS'), ), 'result' => array( - 'node__comment' => array( + 'comment' => array( $comments['published_published']->cid->value => $comment_labels['published_published'], $comments['published_unpublished']->cid->value => $comment_labels['published_unpublished'], $comments['unpublished_published']->cid->value => $comment_labels['unpublished_published'], diff --git a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php index fcc599c..2d662fd 100644 --- a/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php +++ b/core/modules/field/tests/modules/field_test/lib/Drupal/field_test/Plugin/Field/FieldType/TestItem.php @@ -77,7 +77,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $form['test_field_setting'] = array( '#type' => 'textfield', '#title' => t('Field test field setting'), diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php index 3739368..b241cdd 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php @@ -162,6 +162,8 @@ public function buildForm(array $form, array &$form_state, FieldInstanceConfigIn $form['actions'] = array('#type' => 'actions'); $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save field settings')); + $form['#submit'][] = array($this, 'submitForm'); + $form['#validate'][] = array($this, 'validateForm'); return $form; } diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php index 16ada1e..0a8e45e 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileItem.php @@ -105,7 +105,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element = array(); $element['#attached']['library'][] = 'file/drupal.file'; diff --git a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php index bf80c17..bac2125 100644 --- a/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php +++ b/core/modules/file/lib/Drupal/file/Tests/FileFieldWidgetTest.php @@ -257,7 +257,7 @@ function testPrivateFileComment() { 'fields[_add_new_field][field_name]' => $name = strtolower($this->randomName()), 'fields[_add_new_field][type]' => 'file', ); - $this->drupalPostForm('admin/structure/comments/manage/node__comment/fields', $edit, t('Save')); + $this->drupalPostForm('admin/structure/comments/manage/comment/fields', $edit, t('Save')); $edit = array('field[settings][uri_scheme]' => 'private'); $this->drupalPostForm(NULL, $edit, t('Save field settings')); $this->drupalPostForm(NULL, array(), t('Save settings')); diff --git a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php index 249933e..17f8ce5 100644 --- a/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php +++ b/core/modules/image/lib/Drupal/image/Plugin/Field/FieldType/ImageItem.php @@ -152,7 +152,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element = array(); // We need the field-level 'default_image' setting, and $this->getSettings() diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml index a9fe824..43da698 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_comment.yml @@ -3,7 +3,8 @@ label: Drupal 6 comments source: plugin: d6_comment constants: - field_id: node__comment + field_name: comment + comment_type: comment entity_type: node process: cid: cid @@ -19,7 +20,8 @@ process: migration: d6_node source: nid entity_type: constants.entity_type - field_id: constants.field_id + field_name: constants.field_name + comment_type: constants.comment_type subject: subject uid: - diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php index 095c89c..5d16585 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListBooleanItem.php @@ -102,7 +102,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $allowed_values = $this->getSetting('allowed_values'); $allowed_values_function = $this->getSetting('allowed_values_function'); diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php index b1816f2..134a71b 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php @@ -71,7 +71,7 @@ public function isEmpty() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $allowed_values = $this->getSetting('allowed_values'); $allowed_values_function = $this->getSetting('allowed_values_function'); diff --git a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php index f152e0b..8157e35 100644 --- a/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php +++ b/core/modules/rdf/lib/Drupal/rdf/Tests/CommentAttributesTest.php @@ -68,7 +68,7 @@ public function setUp() { $user_mapping->setFieldMapping('homepage', array('properties' => array('foaf:page'), 'mapping_type' => 'rel'))->save(); // Save comment mapping. - $mapping = rdf_get_mapping('comment', 'node__comment'); + $mapping = rdf_get_mapping('comment', 'comment'); $mapping->setBundleMapping(array('types' => array('sioc:Post', 'sioct:Comment')))->save(); $field_mappings = array( 'subject' => array( diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php index a893063..8b609b3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldType/TaxonomyTermReferenceItem.php @@ -118,7 +118,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $vocabularies = entity_load_multiple('taxonomy_vocabulary'); $options = array(); foreach ($vocabularies as $vocabulary) { diff --git a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php index b2ba0a1..6bacea6 100644 --- a/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php +++ b/core/modules/text/lib/Drupal/text/Plugin/Field/FieldType/TextItem.php @@ -78,7 +78,7 @@ public function getConstraints() { /** * {@inheritdoc} */ - public function settingsForm(array $form, array &$form_state, $has_data) { + public function settingsForm(array &$form, array &$form_state, $has_data) { $element = array(); $element['max_length'] = array(