Commit 0cde5d75 authored by catch's avatar catch

Issue #2321385 by alexpott, bircher, amateescu, swentel, benjy: Fixed Creation...

Issue #2321385 by alexpott, bircher, amateescu, swentel, benjy: Fixed Creation of node body field in postSave() incompatible with default config and overrides.
parent 9792a0de
# 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
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: { }
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: { }
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: { }
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
type: book
langcode: en
status: true
dependencies: { }
name: 'Book page'
type: book
description: '<em>Books</em> 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: { }
......@@ -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
......
......@@ -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(
......
......@@ -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);
}
/**
......
......@@ -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();
......
......@@ -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 <a href="@link">Manage fields</a> page.', array('@link' => \Drupal::url('field_ui.overview_node', array('node_type' => 'no_fields')))));
......
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: { }
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: { }
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: forum
mode: default
content:
taxonomy_forums:
type: taxonomy_term_reference_link
weight: 10
label: above
settings: { }
third_party_settings: { }
comment_forum:
label: hidden
type: comment_default
weight: 20
settings:
pager_id: '0'
third_party_settings: { }
body:
label: hidden
type: text_default
weight: 100
settings: { }
third_party_settings: { }
links:
weight: 101
hidden:
langcode: true
third_party_settings: { }
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: forum
mode: teaser
content:
taxonomy_forums:
type: taxonomy_term_reference_link
weight: 10
label: above
settings: { }
third_party_settings: { }
body:
label: hidden
type: text_summary_or_trimmed
weight: 100
settings:
trim_length: 600
third_party_settings: { }
links:
weight: 101
hidden:
langcode: true
comment_forum: true
third_party_settings: { }
langcode: en
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: { }
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
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
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
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
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
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: { }
......@@ -9,6 +9,7 @@
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\comment\CommentManagerInterface;
use Drupal\taxonomy\Entity\Term;
/**
* Implements hook_install().
......@@ -22,65 +23,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 = Term::create(array(
'name' => t('General discussion'),
'description' => '',
'parent' => array(0),
'vid' => 'forums',
'forum_container' => 0,