Issue #2321385 by alexpott, bircher, amateescu, swentel, benjy: Fixed Creation of node body field in postSave() incompatible with default config and overrides.
parent
9792a0de23
commit
0cde5d7536
|
@ -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
|
||||
|
|
|
@ -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: { }
|
|
@ -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: { }
|
|
@ -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: { }
|
|
@ -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
|
|
@ -1,9 +1,11 @@
|
|||
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 @@ class ConfigImportRecreateTest extends DrupalUnitTestBase {
|
|||
'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 @@ class ConfigImportRecreateTest extends DrupalUnitTestBase {
|
|||
'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 @@ class ConfigTranslationListUiTest extends WebTestBase {
|
|||
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 @@ class ConfigTranslationListUiTest extends WebTestBase {
|
|||
*/
|
||||
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 @@ class EditorFileUsageTest extends EntityUnitTestBase {
|
|||
// 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 @@ class EntityDisplayTest extends KernelTestBase {
|
|||
*/
|
||||
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 @@ class ManageDisplayTest extends FieldUiTestBase {
|
|||
*/
|
||||
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')))));
|
||||
|
|
|
@ -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: { }
|
|
@ -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: { }
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
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: { }
|
|
@ -0,0 +1,38 @@
|
|||
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: { }
|
|
@ -1,8 +1,15 @@
|
|||
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: { }
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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: { }
|
||||
|
|
|
@ -9,6 +9,7 @@ use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
|||
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,
|
||||
));
|
||||
$term->save();
|
||||
// Add the comment field to the forum node type.
|
||||
$field_storages = entity_load_multiple_by_properties('field_storage_config', array(
|
||||
'type' => 'comment',
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\migrate\Plugin\migrate\destination\EntityNodeType.
|
||||
*/
|
||||
|
||||
namespace Drupal\migrate\Plugin\migrate\destination;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
|
||||
/**
|
||||
* @MigrateDestination(
|
||||
* id = "entity:node_type"
|
||||
* )
|
||||
*/
|
||||
class EntityNodeType extends EntityConfigBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function import(Row $row, array $old_destination_id_values = array()) {
|
||||
$entity_ids = parent::import($row, $old_destination_id_values);
|
||||
if ($row->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;
|
||||
}
|
||||
|
||||
}
|
|
@ -22,7 +22,9 @@ abstract class MigrateNodeTestBase extends MigrateDrupalTestBase {
|
|||
*/
|
||||
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);
|
||||
|
|
|
@ -96,28 +96,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}
|
||||
*/
|
||||
|
@ -181,15 +159,7 @@ class NodeType extends ConfigEntityBundleBase implements NodeTypeInterface {
|
|||
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,
|
||||
|
|
|
@ -230,6 +230,7 @@ class NodeTypeForm extends EntityForm {
|
|||
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);
|
||||
|
|
|
@ -45,7 +45,9 @@ class NodeBodyFieldStorageTest extends KernelTestBase {
|
|||
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');
|
||||
|
|
|
@ -39,11 +39,10 @@ class NodeTypeRenameConfigImportTest extends WebTestBase {
|
|||
* 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.
|
||||
|
|
|
@ -275,6 +275,7 @@ abstract class WebTestBase extends TestBase {
|
|||
);
|
||||
$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())));
|
||||
|
|
|
@ -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: { }
|
||||
|
|
|
@ -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: { }
|
|
@ -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: { }
|
||||
|
|
|
@ -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: { }
|
|
@ -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: { }
|
||||
|
|
|
@ -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: { }
|
|
@ -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: { }
|
|
@ -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
|
|
@ -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
|
Loading…
Reference in New Issue