diff --git a/core/modules/book/config/install/field.instance.node.book.body.yml b/core/modules/book/config/install/field.instance.node.book.body.yml new file mode 100644 index 0000000..3c422c4 --- /dev/null +++ b/core/modules/book/config/install/field.instance.node.book.body.yml @@ -0,0 +1,20 @@ +langcode: en +status: true +dependencies: + entity: + - field.storage.node.body + - node.type.book +id: node.book.body +label: Body +field_name: body +entity_type: node +bundle: book +description: '' +required: false +translatable: true +default_value: { } +default_value_function: '' +settings: + display_summary: true + text_processing: true +field_type: text_with_summary diff --git a/core/modules/forum/config/install/field.instance.node.forum.body.yml b/core/modules/forum/config/install/field.instance.node.forum.body.yml new file mode 100644 index 0000000..3a9301b --- /dev/null +++ b/core/modules/forum/config/install/field.instance.node.forum.body.yml @@ -0,0 +1,20 @@ +langcode: en +status: true +dependencies: + entity: + - field.storage.node.body + - node.type.forum +id: node.forum.body +label: Body +field_name: body +entity_type: node +bundle: forum +description: '' +required: false +translatable: true +default_value: { } +default_value_function: '' +settings: + display_summary: true + text_processing: true +field_type: text_with_summary diff --git a/core/modules/node/config/install/field.storage.node.body.yml b/core/modules/node/config/install/field.storage.node.body.yml new file mode 100644 index 0000000..fdf2b1f --- /dev/null +++ b/core/modules/node/config/install/field.storage.node.body.yml @@ -0,0 +1,16 @@ +langcode: en +status: true +dependencies: + module: + - node + - text +id: node.body +name: body +entity_type: node +type: text_with_summary +settings: { } +module: text +locked: false +cardinality: 1 +translatable: true +indexes: { } diff --git a/core/modules/node/src/Entity/NodeType.php b/core/modules/node/src/Entity/NodeType.php index 57fc6f6..1931c75 100644 --- a/core/modules/node/src/Entity/NodeType.php +++ b/core/modules/node/src/Entity/NodeType.php @@ -145,15 +145,7 @@ public function isLocked() { 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 ($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 c99045f..a529c85 100644 --- a/core/modules/node/src/NodeTypeForm.php +++ b/core/modules/node/src/NodeTypeForm.php @@ -192,6 +192,11 @@ public function save(array $form, FormStateInterface $form_state) { drupal_set_message(t('The content type %name has been added.', $t_args)); $context = array_merge($t_args, array('link' => l(t('View'), 'admin/structure/types'))); $this->logger('node')->notice('Added content type %name.', $context); + // Create a body if the create_body property is true + if ($type->get('create_body')) { + $label = $type->get('create_body_label'); + node_add_body_field($type, $label); + } } $form_state->setRedirect('node.overview_types'); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 89ff9db..6d9b533 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -307,6 +307,9 @@ protected function drupalCreateContentType(array $values = array()) { ); $type = entity_create('node_type', $values); $status = $type->save(); + // Add the body field as the form does. + $label = $type->get('create_body_label'); + node_add_body_field($type, $label); \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/field.instance.node.article.body.yml b/core/profiles/standard/config/install/field.instance.node.article.body.yml new file mode 100644 index 0000000..2a2c69c --- /dev/null +++ b/core/profiles/standard/config/install/field.instance.node.article.body.yml @@ -0,0 +1,20 @@ +langcode: en +status: true +dependencies: + entity: + - field.storage.node.body + - node.type.article +id: node.article.body +label: Body +field_name: body +entity_type: node +bundle: article +description: '' +required: false +translatable: true +default_value: { } +default_value_function: '' +settings: + display_summary: true + text_processing: true +field_type: text_with_summary diff --git a/core/profiles/standard/config/install/field.instance.node.page.body.yml b/core/profiles/standard/config/install/field.instance.node.page.body.yml new file mode 100644 index 0000000..4b806c0 --- /dev/null +++ b/core/profiles/standard/config/install/field.instance.node.page.body.yml @@ -0,0 +1,20 @@ +langcode: en +status: true +dependencies: + entity: + - field.storage.node.body + - node.type.page +id: node.page.body +label: Body +field_name: body +entity_type: node +bundle: page +description: '' +required: false +translatable: true +default_value: { } +default_value_function: '' +settings: + display_summary: true + text_processing: true +field_type: text_with_summary