diff --git a/core/modules/node/lib/Drupal/node/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Entity/NodeType.php index 67136b3..0fb1ecc 100644 --- a/core/modules/node/lib/Drupal/node/Entity/NodeType.php +++ b/core/modules/node/lib/Drupal/node/Entity/NodeType.php @@ -103,6 +103,19 @@ class NodeType extends ConfigEntityBase implements NodeTypeInterface { public $title_label = 'Title'; /** + * 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 @@ -157,9 +170,9 @@ public function postSave(EntityStorageControllerInterface $storage_controller, $ entity_invoke_bundle_hook('create', 'node', $this->id()); - // Automatically create a body field for new node types if not in the - // syncing process. - if (!$this->isSyncing()) { + // 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); } diff --git a/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php b/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php index 0a1db9c..764d96c 100644 --- a/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/Config/NodeImportCreateTest.php @@ -78,6 +78,7 @@ public function testImportCreate() { // Check that the content type was created. $node_type = entity_load('node_type', $node_type_id); $this->assertTrue($node_type, 'Import node type from staging was created.'); + $this->assertFalse(field_info_instance('node', 'body', $node_type_id)); } }