diff --git a/core/modules/book/config/install/core.base_field_override.node.book.promote.yml b/core/modules/book/config/install/core.base_field_override.node.book.promote.yml index f747d77..600d04a 100644 --- a/core/modules/book/config/install/core.base_field_override.node.book.promote.yml +++ b/core/modules/book/config/install/core.base_field_override.node.book.promote.yml @@ -1,4 +1,3 @@ -# Changes the default value of the promote base field on the book node type. langcode: en status: true dependencies: @@ -17,4 +16,5 @@ default_value: value: 0 default_value_callback: '' settings: { } +third_party_settings: { } field_type: boolean diff --git a/core/modules/book/config/install/core.entity_form_display.node.book.default.yml b/core/modules/book/config/install/core.entity_form_display.node.book.default.yml new file mode 100644 index 0000000..6b95416 --- /dev/null +++ b/core/modules/book/config/install/core.entity_form_display.node.book.default.yml @@ -0,0 +1,57 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.book.body + - node.type.book + module: + - entity_reference + - text +id: node.book.default +targetEntityType: node +bundle: book +mode: default +content: + title: + type: string_textfield + weight: -5 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + uid: + type: entity_reference_autocomplete + weight: 5 + settings: + match_operator: CONTAINS + size: 60 + autocomplete_type: tags + placeholder: '' + third_party_settings: { } + created: + type: datetime_timestamp + weight: 10 + settings: { } + third_party_settings: { } + promote: + type: boolean_checkbox + settings: + display_label: '1' + weight: 15 + third_party_settings: { } + sticky: + type: boolean_checkbox + settings: + display_label: '1' + weight: 16 + third_party_settings: { } + body: + type: text_textarea_with_summary + weight: 26 + settings: + rows: 9 + summary_rows: 3 + placeholder: '' + third_party_settings: { } +hidden: { } +third_party_settings: { } diff --git a/core/modules/book/config/install/core.entity_view_display.node.book.default.yml b/core/modules/book/config/install/core.entity_view_display.node.book.default.yml new file mode 100644 index 0000000..e4f76fd --- /dev/null +++ b/core/modules/book/config/install/core.entity_view_display.node.book.default.yml @@ -0,0 +1,26 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.book.body + - node.type.book + module: + - text + - user +id: node.book.default +label: null +targetEntityType: node +bundle: book +mode: default +content: + body: + label: hidden + type: text_default + weight: 100 + settings: { } + third_party_settings: { } + links: + weight: 101 +hidden: + langcode: true +third_party_settings: { } diff --git a/core/modules/book/config/install/core.entity_view_display.node.book.teaser.yml b/core/modules/book/config/install/core.entity_view_display.node.book.teaser.yml new file mode 100644 index 0000000..4e2dd37 --- /dev/null +++ b/core/modules/book/config/install/core.entity_view_display.node.book.teaser.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.teaser + - field.field.node.book.body + - node.type.book + module: + - text + - user +id: node.book.teaser +label: null +targetEntityType: node +bundle: book +mode: teaser +content: + body: + label: hidden + type: text_summary_or_trimmed + weight: 100 + settings: + trim_length: 600 + third_party_settings: { } + links: + weight: 101 +hidden: + langcode: true +third_party_settings: { } diff --git a/core/modules/book/config/install/field.field.node.book.body.yml b/core/modules/book/config/install/field.field.node.book.body.yml new file mode 100644 index 0000000..4c128b6 --- /dev/null +++ b/core/modules/book/config/install/field.field.node.book.body.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.body + - node.type.book + module: + - text +id: node.book.body +field_name: body +entity_type: node +bundle: book +label: Body +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + display_summary: true +third_party_settings: { } +field_type: text_with_summary diff --git a/core/modules/book/config/install/node.type.book.yml b/core/modules/book/config/install/node.type.book.yml index 172eaaf..2fb20c3 100644 --- a/core/modules/book/config/install/node.type.book.yml +++ b/core/modules/book/config/install/node.type.book.yml @@ -1,9 +1,11 @@ -type: book +langcode: en +status: true +dependencies: { } name: 'Book page' +type: book description: 'Books have a built-in hierarchical navigation. Use for handbooks or tutorials.' help: '' new_revision: false -display_submitted: true preview_mode: 1 -status: true -langcode: en +display_submitted: true +third_party_settings: { } diff --git a/core/modules/config/src/Tests/ConfigImportRecreateTest.php b/core/modules/config/src/Tests/ConfigImportRecreateTest.php index 1da42fd..19affec 100644 --- a/core/modules/config/src/Tests/ConfigImportRecreateTest.php +++ b/core/modules/config/src/Tests/ConfigImportRecreateTest.php @@ -66,6 +66,7 @@ public function testRecreateEntity() { 'name' => 'Node type one', )); $content_type->save(); + node_add_body_field($content_type); /** @var \Drupal\Core\Config\StorageInterface $active */ $active = $this->container->get('config.storage'); /** @var \Drupal\Core\Config\StorageInterface $staging */ @@ -84,6 +85,7 @@ public function testRecreateEntity() { 'name' => 'Node type two', )); $content_type->save(); + node_add_body_field($content_type); $this->configImporter->reset(); // A node type, a field, an entity view display and an entity form display diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index 3d7c0c3..cedb790 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -232,11 +232,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 = entity_create('node_type', array( + $content_type = $this->drupalCreateContentType(array( 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), )); - $content_type->save(); // Get the content type listing. $this->drupalGet('admin/structure/types'); @@ -383,11 +382,10 @@ public function doResponsiveImageListTest() { */ public function doFieldListTest() { // Create a base content type. - $content_type = entity_create('node_type', array( + $content_type = $this->drupalCreateContentType(array( 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), )); - $content_type->save(); // Look at a few fields on a few entity types. $pages = array( diff --git a/core/modules/editor/src/Tests/EditorFileUsageTest.php b/core/modules/editor/src/Tests/EditorFileUsageTest.php index 1a6d844..999662b 100644 --- a/core/modules/editor/src/Tests/EditorFileUsageTest.php +++ b/core/modules/editor/src/Tests/EditorFileUsageTest.php @@ -48,6 +48,7 @@ protected function setUp() { // Create a node type for testing. $type = entity_create('node_type', array('type' => 'page', 'name' => 'page')); $type->save(); + node_add_body_field($type); } /** diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index e6effec..82003d8 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -270,12 +270,13 @@ public function testBaseFieldComponent() { */ public function testRenameDeleteBundle() { // Create a node bundle, display and form display object. - entity_create('node_type', array('type' => 'article'))->save(); + $type = entity_create('node_type', array('type' => 'article')); + $type->save(); + node_add_body_field($type); entity_get_display('node', 'article', 'default')->save(); entity_get_form_display('node', 'article', 'default')->save(); // Rename the article bundle and assert the entity display is renamed. - $type = node_type_load('article'); $type->old_type = 'article'; $type->type = 'article_rename'; $type->save(); diff --git a/core/modules/field_ui/src/Tests/ManageDisplayTest.php b/core/modules/field_ui/src/Tests/ManageDisplayTest.php index 4839309..1252239 100644 --- a/core/modules/field_ui/src/Tests/ManageDisplayTest.php +++ b/core/modules/field_ui/src/Tests/ManageDisplayTest.php @@ -364,11 +364,10 @@ function testSingleViewMode() { */ function testNoFieldsDisplayOverview() { // Create a fresh content type without any fields. - $this->drupalCreateContentType(array( + entity_create('node_type', array( 'type' => 'no_fields', 'name' => 'No fields', - 'create_body' => FALSE, - )); + ))->save(); $this->drupalGet('admin/structure/types/manage/no_fields/display'); $this->assertRaw(t('There are no fields yet added. You can add new fields on the Manage fields page.', array('@link' => \Drupal::url('field_ui.overview_node', array('node_type' => 'no_fields'))))); diff --git a/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml b/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml new file mode 100644 index 0000000..c8df303 --- /dev/null +++ b/core/modules/forum/config/install/core.entity_form_display.node.forum.default.yml @@ -0,0 +1,70 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.forum.body + - field.field.node.forum.comment_forum + - field.field.node.forum.taxonomy_forums + - node.type.forum + module: + - comment + - entity_reference + - text +id: node.forum.default +targetEntityType: node +bundle: forum +mode: default +content: + title: + type: string_textfield + weight: -5 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + uid: + type: entity_reference_autocomplete + weight: 5 + settings: + match_operator: CONTAINS + size: 60 + autocomplete_type: tags + placeholder: '' + third_party_settings: { } + created: + type: datetime_timestamp + weight: 10 + settings: { } + third_party_settings: { } + promote: + type: boolean_checkbox + settings: + display_label: '1' + weight: 15 + third_party_settings: { } + sticky: + type: boolean_checkbox + settings: + display_label: '1' + weight: 16 + third_party_settings: { } + comment_forum: + type: comment_default + weight: 20 + settings: { } + third_party_settings: { } + body: + type: text_textarea_with_summary + weight: 26 + settings: + rows: 9 + summary_rows: 3 + placeholder: '' + third_party_settings: { } + taxonomy_forums: + type: options_select + weight: 27 + settings: { } + third_party_settings: { } +hidden: { } +third_party_settings: { } diff --git a/core/modules/forum/config/install/core.entity_form_display.taxonomy_term.forums.default.yml b/core/modules/forum/config/install/core.entity_form_display.taxonomy_term.forums.default.yml index 1d8fb47..dfca846 100644 --- a/core/modules/forum/config/install/core.entity_form_display.taxonomy_term.forums.default.yml +++ b/core/modules/forum/config/install/core.entity_form_display.taxonomy_term.forums.default.yml @@ -1,8 +1,14 @@ +langcode: en +status: true +dependencies: + config: + - taxonomy.vocabulary.forums + module: + - text id: taxonomy_term.forums.default targetEntityType: taxonomy_term bundle: forums mode: default -status: true content: name: type: string_textfield @@ -14,8 +20,7 @@ content: description: type: text_textfield weight: 0 - settings: { } + settings: { } third_party_settings: { } -dependencies: - config: - - taxonomy.vocabulary.forums +hidden: { } +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml b/core/modules/forum/config/install/core.entity_view_display.node.forum.default.yml similarity index 50% copy from core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml copy to core/modules/forum/config/install/core.entity_view_display.node.forum.default.yml index fb6f75d..fc80319 100644 --- a/core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml +++ b/core/modules/forum/config/install/core.entity_view_display.node.forum.default.yml @@ -1,37 +1,43 @@ -id: node.article.default +langcode: en +status: true +dependencies: + config: + - field.field.node.forum.body + - field.field.node.forum.comment_forum + - field.field.node.forum.taxonomy_forums + - node.type.forum + module: + - comment + - taxonomy + - text + - user +id: node.forum.default +label: null targetEntityType: node -bundle: article +bundle: forum mode: default -status: true content: - field_image: - type: image - weight: -1 - settings: - image_style: large - image_link: '' + taxonomy_forums: + type: taxonomy_term_reference_link + weight: 10 + label: above + settings: { } third_party_settings: { } + comment_forum: label: hidden - body: - type: text_default - weight: 0 - settings: { } + type: comment_default + weight: 20 + settings: + pager_id: '0' third_party_settings: { } + body: label: hidden - field_tags: - type: taxonomy_term_reference_link - weight: 10 - label: above + type: text_default + weight: 100 settings: { } third_party_settings: { } -dependencies: - config: - - field.field.node.article.body - - field.field.node.article.field_image - - field.field.node.article.field_tags - - node.type.article - module: - - comment - - image - - taxonomy - - text + links: + weight: 101 +hidden: + langcode: true +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml b/core/modules/forum/config/install/core.entity_view_display.node.forum.teaser.yml similarity index 51% copy from core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml copy to core/modules/forum/config/install/core.entity_view_display.node.forum.teaser.yml index 7f8ed57..eedea3e 100644 --- a/core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml +++ b/core/modules/forum/config/install/core.entity_view_display.node.forum.teaser.yml @@ -1,38 +1,38 @@ -id: node.article.teaser +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.teaser + - field.field.node.forum.body + - field.field.node.forum.comment_forum + - field.field.node.forum.taxonomy_forums + - node.type.forum + module: + - taxonomy + - text + - user +id: node.forum.teaser +label: null targetEntityType: node -bundle: article +bundle: forum mode: teaser -status: true content: - field_image: - type: image - weight: -1 - settings: - image_style: medium - image_link: content + taxonomy_forums: + type: taxonomy_term_reference_link + weight: 10 + label: above + settings: { } third_party_settings: { } - label: hidden body: + label: hidden type: text_summary_or_trimmed - weight: 0 + weight: 100 settings: trim_length: 600 third_party_settings: { } - label: hidden - field_tags: - type: taxonomy_term_reference_link - weight: 10 - settings: { } - third_party_settings: { } - label: above -dependencies: - config: - - core.entity_view_mode.node.teaser - - field.field.node.article.body - - field.field.node.article.field_image - - field.field.node.article.field_tags - - node.type.article - module: - - image - - taxonomy - - text + links: + weight: 101 +hidden: + langcode: true + comment_forum: true +third_party_settings: { } diff --git a/core/modules/forum/config/install/core.entity_view_display.taxonomy_term.forums.default.yml b/core/modules/forum/config/install/core.entity_view_display.taxonomy_term.forums.default.yml index 8984c3c..667e478 100644 --- a/core/modules/forum/config/install/core.entity_view_display.taxonomy_term.forums.default.yml +++ b/core/modules/forum/config/install/core.entity_view_display.taxonomy_term.forums.default.yml @@ -1,8 +1,15 @@ +langcode: und +status: true +dependencies: + config: + - taxonomy.vocabulary.forums + module: + - text id: taxonomy_term.forums.default +label: null targetEntityType: taxonomy_term bundle: forums mode: default -status: true content: description: type: text_default @@ -11,7 +18,4 @@ content: third_party_settings: { } label: above hidden: { } -status: true -dependencies: - config: - - taxonomy.vocabulary.forums +third_party_settings: { } diff --git a/core/modules/forum/config/install/field.field.node.forum.body.yml b/core/modules/forum/config/install/field.field.node.forum.body.yml new file mode 100644 index 0000000..279f160 --- /dev/null +++ b/core/modules/forum/config/install/field.field.node.forum.body.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.body + - node.type.forum + module: + - text +id: node.forum.body +field_name: body +entity_type: node +bundle: forum +label: Body +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + display_summary: true +third_party_settings: { } +field_type: text_with_summary diff --git a/core/modules/forum/config/install/field.field.node.forum.taxonomy_forums.yml b/core/modules/forum/config/install/field.field.node.forum.taxonomy_forums.yml new file mode 100644 index 0000000..9847752 --- /dev/null +++ b/core/modules/forum/config/install/field.field.node.forum.taxonomy_forums.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.taxonomy_forums + - node.type.forum + module: + - taxonomy +id: node.forum.taxonomy_forums +field_name: taxonomy_forums +entity_type: node +bundle: forum +label: Forums +description: '' +required: true +translatable: true +default_value: { } +default_value_callback: '' +settings: + handler: default +third_party_settings: { } +field_type: taxonomy_term_reference diff --git a/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml b/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml index 3f4cd1e..3aeedc1 100644 --- a/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml +++ b/core/modules/forum/config/install/field.field.taxonomy_term.forums.forum_container.yml @@ -1,19 +1,21 @@ -id: taxonomy_term.forums.forum_container -status: true langcode: en +status: true +dependencies: + config: + - field.storage.taxonomy_term.forum_container + - taxonomy.vocabulary.forums +id: taxonomy_term.forums.forum_container +field_name: forum_container entity_type: taxonomy_term bundle: forums -field_name: forum_container label: Container description: '' required: true +translatable: true default_value: - value: 0 default_value_callback: '' settings: { } +third_party_settings: { } field_type: boolean -dependencies: - config: - - field.storage.taxonomy_term.forum_container - - taxonomy.vocabulary.forums diff --git a/core/modules/forum/config/install/field.storage.node.taxonomy_forums.yml b/core/modules/forum/config/install/field.storage.node.taxonomy_forums.yml new file mode 100644 index 0000000..e05c0df --- /dev/null +++ b/core/modules/forum/config/install/field.storage.node.taxonomy_forums.yml @@ -0,0 +1,24 @@ +langcode: en +status: true +dependencies: + module: + - node + - taxonomy +id: node.taxonomy_forums +field_name: taxonomy_forums +entity_type: node +type: taxonomy_term_reference +settings: + allowed_values: + - + vocabulary: forums + parent: 0 + target_type: taxonomy_term + options_list_callback: null + target_bundle: null +module: taxonomy +locked: false +cardinality: 1 +translatable: true +indexes: { } +persist_with_no_fields: false diff --git a/core/modules/forum/config/install/field.storage.taxonomy_term.forum_container.yml b/core/modules/forum/config/install/field.storage.taxonomy_term.forum_container.yml index b442e27..d57b575 100644 --- a/core/modules/forum/config/install/field.storage.taxonomy_term.forum_container.yml +++ b/core/modules/forum/config/install/field.storage.taxonomy_term.forum_container.yml @@ -1,19 +1,18 @@ -id: taxonomy_term.forum_container -status: true langcode: en +status: true +dependencies: + module: + - taxonomy +id: taxonomy_term.forum_container field_name: forum_container +entity_type: taxonomy_term type: boolean settings: on_label: Yes off_label: No -module: options -entity_type: taxonomy_term +module: core locked: true cardinality: 1 translatable: false indexes: { } -dependencies: - module: - - options - - taxonomy persist_with_no_fields: false diff --git a/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml b/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml index 74d64ca..6ed487b 100644 --- a/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml +++ b/core/modules/forum/config/install/taxonomy.vocabulary.forums.yml @@ -1,7 +1,9 @@ -vid: forums +langcode: en +status: true +dependencies: { } name: Forums +vid: forums description: 'Forum navigation vocabulary' hierarchy: 1 weight: -10 -status: true -langcode: en +third_party_settings: { } diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install index 6605c1d..f7da70d 100644 --- a/core/modules/forum/forum.install +++ b/core/modules/forum/forum.install @@ -22,65 +22,15 @@ function forum_install() { \Drupal::state()->set('node.type.locked', $locked); if (!\Drupal::service('config.installer')->isSyncing()) { - // Create the 'taxonomy_forums' field if it doesn't already exist. If forum - // is being enabled at the same time as taxonomy after both modules have been - // enabled, the field might exist but still be marked inactive. - if (!FieldStorageConfig::loadByName('node', 'taxonomy_forums')) { - entity_create('field_storage_config', array( - 'field_name' => 'taxonomy_forums', - 'entity_type' => 'node', - 'type' => 'taxonomy_term_reference', - 'settings' => array( - 'allowed_values' => array( - array( - 'vocabulary' => 'forums', - 'parent' => 0, - ), - ), - ), - ))->save(); - - // Create a default forum so forum posts can be created. - $term = entity_create('taxonomy_term', array( - 'name' => t('General discussion'), - 'description' => '', - 'parent' => array(0), - 'vid' => 'forums', - 'forum_container' => 0, - )); - $term->save(); - - // Create the instance on the bundle. - entity_create('field_config', array( - 'field_name' => 'taxonomy_forums', - 'entity_type' => 'node', - 'label' => 'Forums', - 'bundle' => 'forum', - 'required' => TRUE, - ))->save(); - - // Assign form display settings for the 'default' form mode. - entity_get_form_display('node', 'forum', 'default') - ->setComponent('taxonomy_forums', array( - 'type' => 'options_select', - )) - ->save(); - - // Assign display settings for the 'default' and 'teaser' view modes. - entity_get_display('node', 'forum', 'default') - ->setComponent('taxonomy_forums', array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - )) - ->save(); - - entity_get_display('node', 'forum', 'teaser') - ->setComponent('taxonomy_forums', array( - 'type' => 'taxonomy_term_reference_link', - 'weight' => 10, - )) - ->save(); - } + // Create a default forum so forum posts can be created. + $term = entity_create('taxonomy_term', array( + 'name' => t('General discussion'), + 'description' => '', + 'parent' => array(0), + 'vid' => 'forums', + 'forum_container' => 0, + )); + $term->save(); // Add the comment field to the forum node type. $field_storages = entity_load_multiple_by_properties('field_storage_config', array( 'type' => 'comment', diff --git a/core/modules/migrate/src/Plugin/migrate/destination/EntityNodeType.php b/core/modules/migrate/src/Plugin/migrate/destination/EntityNodeType.php new file mode 100644 index 0000000..a6bee84 --- /dev/null +++ b/core/modules/migrate/src/Plugin/migrate/destination/EntityNodeType.php @@ -0,0 +1,31 @@ +getDestinationProperty('create_body')) { + $node_type = $this->storage->load(reset($entity_ids)); + node_add_body_field($node_type, $row->getDestinationProperty('create_body_label')); + } + return $entity_ids; + } + +} diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php index 72cef7e..d8ab3e6 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateNodeTestBase.php @@ -22,7 +22,9 @@ */ protected function setUp() { parent::setUp(); - entity_create('node_type', array('type' => 'test_planet'))->save(); + $node_type = entity_create('node_type', array('type' => 'test_planet')); + $node_type->save(); + node_add_body_field($node_type); $node_type = entity_create('node_type', array('type' => 'story')); $node_type->save(); node_add_body_field($node_type); diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php index 73e1202..e33c1ec 100644 --- a/core/modules/node/src/Entity/NodeType.php +++ b/core/modules/node/src/Entity/NodeType.php @@ -97,28 +97,6 @@ class NodeType extends ConfigEntityBundleBase implements NodeTypeInterface { protected $display_submitted = TRUE; /** - * Indicates whether a Body field should be created for this node type. - * - * This property affects entity creation only. It allows default configuration - * of modules and installation profiles to specify whether a Body field should - * be created for this bundle. - * - * @var bool - * - * @see \Drupal\node\Entity\NodeType::$create_body_label - */ - protected $create_body = TRUE; - - /** - * The label to use for the Body field upon entity creation. - * - * @see \Drupal\node\Entity\NodeType::$create_body - * - * @var string - */ - protected $create_body_label = 'Body'; - - /** * {@inheritdoc} */ public function id() { @@ -181,15 +159,7 @@ public function setPreviewMode($preview_mode) { public function postSave(EntityStorageInterface $storage, $update = TRUE) { parent::postSave($storage, $update); - if (!$update) { - // Create a body if the create_body property is true and we're not in - // the syncing process. - if ($this->get('create_body') && !$this->isSyncing()) { - $label = $this->get('create_body_label'); - node_add_body_field($this, $label); - } - } - elseif ($this->getOriginalId() != $this->id()) { + if ($update && $this->getOriginalId() != $this->id()) { $update_count = node_type_update_nodes($this->getOriginalId(), $this->id()); if ($update_count) { drupal_set_message(format_plural($update_count, diff --git a/core/modules/node/src/NodeTypeForm.php b/core/modules/node/src/NodeTypeForm.php index 087409c..9335b1b 100644 --- a/core/modules/node/src/NodeTypeForm.php +++ b/core/modules/node/src/NodeTypeForm.php @@ -230,6 +230,7 @@ public function save(array $form, FormStateInterface $form_state) { drupal_set_message(t('The content type %name has been updated.', $t_args)); } elseif ($status == SAVED_NEW) { + node_add_body_field($type); drupal_set_message(t('The content type %name has been added.', $t_args)); $context = array_merge($t_args, array('link' => $this->l(t('View'), new Url('node.overview_types')))); $this->logger('node')->notice('Added content type %name.', $context); diff --git a/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php b/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php index f4c56ce..1ee3781 100644 --- a/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php +++ b/core/modules/node/src/Tests/NodeBodyFieldStorageTest.php @@ -45,7 +45,9 @@ protected function setUp() { public function testFieldOverrides() { $field_storage = FieldStorageConfig::loadByName('node', 'body'); $this->assertTrue($field_storage, 'Node body field storage exists.'); - NodeType::create(['name' => 'Ponies', 'type' => 'ponies'])->save(); + $type = NodeType::create(['name' => 'Ponies', 'type' => 'ponies']); + $type->save(); + node_add_body_field($type); $field_storage = FieldStorageConfig::loadByName('node', 'body'); $this->assertTrue(count($field_storage->getBundles()) == 1, 'Node body field storage is being used on the new node type.'); $field = FieldConfig::loadByName('node', 'ponies', 'body'); diff --git a/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php b/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php index 75973e0..5497ee8 100644 --- a/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php +++ b/core/modules/node/src/Tests/NodeTypeRenameConfigImportTest.php @@ -39,11 +39,10 @@ protected function setUp() { * Tests configuration renaming. */ public function testConfigurationRename() { - $content_type = entity_create('node_type', array( + $content_type = $this->drupalCreateContentType(array( 'type' => Unicode::strtolower($this->randomMachineName(16)), 'name' => $this->randomMachineName(), )); - $content_type->save(); $staged_type = $content_type->type; // Check the default status value for a node of this type. diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index a8568d6..37aff1d 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -275,6 +275,7 @@ protected function drupalCreateContentType(array $values = array()) { ); $type = entity_create('node_type', $values); $status = $type->save(); + node_add_body_field($type); \Drupal::service('router.builder')->rebuild(); $this->assertEqual($status, SAVED_NEW, String::format('Created content type %type.', array('%type' => $type->id()))); diff --git a/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml b/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml index 4a74b69..243f1d6 100644 --- a/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml +++ b/core/profiles/standard/config/install/core.entity_form_display.node.article.default.yml @@ -1,3 +1,19 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.article.body + - field.field.node.article.comment + - field.field.node.article.field_image + - field.field.node.article.field_tags + - node.type.article + module: + - comment + - entity_reference + - image + - path + - taxonomy + - text id: node.article.default targetEntityType: node bundle: article @@ -18,11 +34,6 @@ content: summary_rows: 3 placeholder: '' third_party_settings: { } - comment: - type: comment_default - weight: 2 - settings: { } - third_party_settings: { } field_tags: type: taxonomy_autocomplete weight: 3 @@ -35,17 +46,41 @@ content: progress_indicator: throbber preview_image_style: thumbnail third_party_settings: { } + uid: + type: entity_reference_autocomplete + weight: 5 + settings: + match_operator: CONTAINS + size: 60 + autocomplete_type: tags + placeholder: '' + third_party_settings: { } + created: + type: datetime_timestamp + weight: 10 + settings: { } + third_party_settings: { } + promote: + type: boolean_checkbox + settings: + display_label: '1' + weight: 15 + third_party_settings: { } + sticky: + type: boolean_checkbox + settings: + display_label: '1' + weight: 16 + third_party_settings: { } + comment: + type: comment_default + weight: 20 + settings: { } + third_party_settings: { } + path: + type: path + weight: 30 + settings: { } + third_party_settings: { } hidden: { } -status: true -dependencies: - config: - - field.field.node.article.body - - field.field.node.article.comment - - field.field.node.article.field_image - - field.field.node.article.field_tags - - node.type.article - module: - - comment - - image - - taxonomy - - text +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml b/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml new file mode 100644 index 0000000..792398d --- /dev/null +++ b/core/profiles/standard/config/install/core.entity_form_display.node.page.default.yml @@ -0,0 +1,63 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.page.body + - node.type.page + module: + - entity_reference + - path + - text +id: node.page.default +targetEntityType: node +bundle: page +mode: default +content: + title: + type: string_textfield + weight: -5 + settings: + size: 60 + placeholder: '' + third_party_settings: { } + uid: + type: entity_reference_autocomplete + weight: 5 + settings: + match_operator: CONTAINS + size: 60 + autocomplete_type: tags + placeholder: '' + third_party_settings: { } + created: + type: datetime_timestamp + weight: 10 + settings: { } + third_party_settings: { } + promote: + type: boolean_checkbox + settings: + display_label: '1' + weight: 15 + third_party_settings: { } + sticky: + type: boolean_checkbox + settings: + display_label: '1' + weight: 16 + third_party_settings: { } + path: + type: path + weight: 30 + settings: { } + third_party_settings: { } + body: + type: text_textarea_with_summary + weight: 31 + settings: + rows: 9 + summary_rows: 3 + placeholder: '' + third_party_settings: { } +hidden: { } +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml b/core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml index fb6f75d..b201e5e 100644 --- a/core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml +++ b/core/profiles/standard/config/install/core.entity_view_display.node.article.default.yml @@ -1,8 +1,23 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.article.body + - field.field.node.article.comment + - field.field.node.article.field_image + - field.field.node.article.field_tags + - node.type.article + module: + - comment + - image + - taxonomy + - text + - user id: node.article.default +label: null targetEntityType: node bundle: article mode: default -status: true content: field_image: type: image @@ -24,14 +39,17 @@ content: label: above settings: { } third_party_settings: { } -dependencies: - config: - - field.field.node.article.body - - field.field.node.article.field_image - - field.field.node.article.field_tags - - node.type.article - module: - - comment - - image - - taxonomy - - text + comment: + label: above + type: comment_default + weight: 20 + settings: + pager_id: '0' + third_party_settings: { } + links: + weight: 100 +hidden: + langcode: true + field_image: true + field_tags: true +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.article.rss.yml b/core/profiles/standard/config/install/core.entity_view_display.node.article.rss.yml new file mode 100644 index 0000000..e5f2a49 --- /dev/null +++ b/core/profiles/standard/config/install/core.entity_view_display.node.article.rss.yml @@ -0,0 +1,27 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.rss + - field.field.node.article.body + - field.field.node.article.comment + - field.field.node.article.field_image + - field.field.node.article.field_tags + - node.type.article + module: + - user +id: node.article.rss +label: null +targetEntityType: node +bundle: article +mode: rss +content: + links: + weight: 100 +hidden: + langcode: true + body: true + comment: true + field_image: true + field_tags: true +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml b/core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml index 7f8ed57..f6e4f63 100644 --- a/core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml +++ b/core/profiles/standard/config/install/core.entity_view_display.node.article.teaser.yml @@ -1,8 +1,23 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.teaser + - field.field.node.article.body + - field.field.node.article.comment + - field.field.node.article.field_image + - field.field.node.article.field_tags + - node.type.article + module: + - image + - taxonomy + - text + - user id: node.article.teaser +label: null targetEntityType: node bundle: article mode: teaser -status: true content: field_image: type: image @@ -25,14 +40,11 @@ content: settings: { } third_party_settings: { } label: above -dependencies: - config: - - core.entity_view_mode.node.teaser - - field.field.node.article.body - - field.field.node.article.field_image - - field.field.node.article.field_tags - - node.type.article - module: - - image - - taxonomy - - text + links: + weight: 100 +hidden: + langcode: true + field_image: true + field_tags: true + comment: true +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.page.default.yml b/core/profiles/standard/config/install/core.entity_view_display.node.page.default.yml new file mode 100644 index 0000000..1ae1bd7 --- /dev/null +++ b/core/profiles/standard/config/install/core.entity_view_display.node.page.default.yml @@ -0,0 +1,26 @@ +langcode: en +status: true +dependencies: + config: + - field.field.node.page.body + - node.type.page + module: + - text + - user +id: node.page.default +label: null +targetEntityType: node +bundle: page +mode: default +content: + body: + label: hidden + type: text_default + weight: 100 + settings: { } + third_party_settings: { } + links: + weight: 101 +hidden: + langcode: true +third_party_settings: { } diff --git a/core/profiles/standard/config/install/core.entity_view_display.node.page.teaser.yml b/core/profiles/standard/config/install/core.entity_view_display.node.page.teaser.yml new file mode 100644 index 0000000..4f60c3c --- /dev/null +++ b/core/profiles/standard/config/install/core.entity_view_display.node.page.teaser.yml @@ -0,0 +1,28 @@ +langcode: en +status: true +dependencies: + config: + - core.entity_view_mode.node.teaser + - field.field.node.page.body + - node.type.page + module: + - text + - user +id: node.page.teaser +label: null +targetEntityType: node +bundle: page +mode: teaser +content: + body: + label: hidden + type: text_summary_or_trimmed + weight: 100 + settings: + trim_length: 600 + third_party_settings: { } + links: + weight: 101 +hidden: + langcode: true +third_party_settings: { } diff --git a/core/profiles/standard/config/install/field.field.node.article.body.yml b/core/profiles/standard/config/install/field.field.node.article.body.yml new file mode 100644 index 0000000..e2cdb3a --- /dev/null +++ b/core/profiles/standard/config/install/field.field.node.article.body.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.body + - node.type.article + module: + - text +id: node.article.body +field_name: body +entity_type: node +bundle: article +label: Body +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + display_summary: true +third_party_settings: { } +field_type: text_with_summary diff --git a/core/profiles/standard/config/install/field.field.node.page.body.yml b/core/profiles/standard/config/install/field.field.node.page.body.yml new file mode 100644 index 0000000..57bb0b0 --- /dev/null +++ b/core/profiles/standard/config/install/field.field.node.page.body.yml @@ -0,0 +1,22 @@ +langcode: en +status: true +dependencies: + config: + - field.storage.node.body + - node.type.page + module: + - text +id: node.page.body +field_name: body +entity_type: node +bundle: page +label: Body +description: '' +required: false +translatable: true +default_value: { } +default_value_callback: '' +settings: + display_summary: true +third_party_settings: { } +field_type: text_with_summary