diff --git a/core/modules/book/book.install b/core/modules/book/book.install
index 2293c46..556758f 100644
--- a/core/modules/book/book.install
+++ b/core/modules/book/book.install
@@ -9,8 +9,11 @@
* Implements hook_install().
*/
function book_install() {
- // Add the node type.
- _book_install_type_create();
+ // Ensure the book node type is available.
+ node_types_rebuild();
+ $types = node_type_get_types();
+ node_add_body_field(entity_create('node_type', (array) $types['book']));
+ variable_set('node_options_book', array('status'));
}
/**
@@ -25,28 +28,6 @@ function book_uninstall() {
}
/**
- * Creates the book content type.
- */
-function _book_install_type_create() {
- // Create an additional node type.
- $book_node_type = array(
- 'type' => 'book',
- 'name' => t('Book page'),
- 'base' => 'node_content',
- 'description' => t('Books have a built-in hierarchical navigation. Use for handbooks or tutorials.'),
- 'custom' => 1,
- 'modified' => 1,
- 'locked' => 0,
- );
-
- $book_node_type = node_type_set_defaults($book_node_type);
- node_type_save($book_node_type);
- node_add_body_field($book_node_type);
- // Default to not promoted.
- variable_set('node_options_book', array('status'));
-}
-
-/**
* Implements hook_schema().
*/
function book_schema() {
diff --git a/core/modules/book/config/node.type.book.yml b/core/modules/book/config/node.type.book.yml
new file mode 100644
index 0000000..522cfe3
--- /dev/null
+++ b/core/modules/book/config/node.type.book.yml
@@ -0,0 +1,12 @@
+type: book
+name: 'Book page'
+base: node_content
+module: node
+description: 'Books have a built-in hierarchical navigation. Use for handbooks or tutorials.'
+help: ''
+custom: '1'
+modified: '0'
+locked: '0'
+disabled: '0'
+has_title: '1'
+title_label: Title
diff --git a/core/modules/forum/config/node.type.forum.yml b/core/modules/forum/config/node.type.forum.yml
new file mode 100644
index 0000000..d669e81
--- /dev/null
+++ b/core/modules/forum/config/node.type.forum.yml
@@ -0,0 +1,12 @@
+type: forum
+name: 'Forum topic'
+base: forum
+module: forum
+description: 'A forum topic starts a new discussion thread within a forum.'
+help: ''
+custom: '1'
+modified: '0'
+locked: '0'
+disabled: '0'
+has_title: '1'
+title_label: Subject
diff --git a/core/modules/forum/forum.install b/core/modules/forum/forum.install
index 56f8402..2334121 100644
--- a/core/modules/forum/forum.install
+++ b/core/modules/forum/forum.install
@@ -107,7 +107,7 @@ function forum_enable() {
// Ensure the forum node type is available.
node_types_rebuild();
$types = node_type_get_types();
- node_add_body_field($types['forum']);
+ node_add_body_field(entity_create('node_type', (array) $types['forum']));
}
/**
diff --git a/core/modules/node/content_types.inc b/core/modules/node/content_types.inc
index 5da3ffb..58606c3 100644
--- a/core/modules/node/content_types.inc
+++ b/core/modules/node/content_types.inc
@@ -109,7 +109,7 @@ function theme_node_admin_overview($variables) {
* @see node_type_form_submit()
* @ingroup forms
*/
-function node_type_form($form, &$form_state, NodeType $type = NULL) {
+function node_type_form($form, &$form_state, $type = NULL) {
// Standard procedure for handling the entity argument in entity forms, taking
// potential form caching and rebuilds properly into account.
// @see http://drupal.org/node/1499596
@@ -117,6 +117,9 @@ function node_type_form($form, &$form_state, NodeType $type = NULL) {
if (!isset($type)) {
$type = entity_create('node_type', array('custom' => 1, 'locked' => 0));
}
+ else {
+ $type = entity_load('node_type', $type->type);
+ }
$form_state['node_type'] = $type;
}
else {
@@ -327,7 +330,7 @@ function node_type_form_submit($form, &$form_state) {
// Remove everything that's been saved already - whatever's left is assumed
// to be a persistent variable.
- // @todo
+ // @todo
foreach ($variables as $key => $value) {
if (isset($type->$key)) {
unset($variables[$key]);
diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php
index 17be06e..70b7583 100644
--- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php
+++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/NodeType.php
@@ -141,7 +141,7 @@ public function id() {
/**
* Overrides Drupal\Core\Config\Entity\ConfigEntityBase::label().
*/
- public function label() {
+ public function label($langcode = NULL) {
return $this->name;
}
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 0bb2ce1..52110e9 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -379,11 +379,18 @@ function node_mark($nid, $timestamp) {
* @return
* An array of node types, as objects, keyed by the type.
*
- * @see _node_types_build()
* @see node_type_load()
*/
function node_type_get_types() {
- return entity_load_multiple('node_type');
+ $node_types = array();
+ $config_names = config_get_storage_names_with_prefix('node.type.');
+ foreach ($config_names as $config_name) {
+ $node_type = config($config_name)->get();
+ if (empty($node_type['disabled'])) {
+ $node_types[$node_type['type']] = (object) $node_type;
+ }
+ }
+ return $node_types;
}
/**
@@ -413,8 +420,6 @@ function node_type_get_base($type) {
*
* @return
* An array of node type labels, keyed by the node type name.
- *
- * @see _node_types_build()
*/
function node_type_get_names() {
$cid = 'node_type:names:' . language(LANGUAGE_TYPE_INTERFACE)->langcode;
@@ -424,7 +429,7 @@ function node_type_get_names() {
$types = node_type_get_types();
$names = array();
foreach ($types as $id => $type) {
- $names[$id] = $type->label();
+ $names[$id] = $type->name;
}
#cache()->set($cid, $names, array('node_type' => array_keys($types)));
cache()->set($cid, $names);
@@ -456,8 +461,8 @@ function node_type_get_label($name) {
* The node type label or FALSE if the node type is not found.
*/
function node_get_type_label($node) {
- $types = _node_types_build()->names;
- return isset($types[$node->type]) ? $types[$node->type] : FALSE;
+ $types = node_type_get_types();
+ return isset($types[$node->type]) ? $types[$node->type]->name : FALSE;
}
/**
@@ -469,8 +474,8 @@ function node_get_type_label($node) {
* @return
* The node type name that is safe for printing.
*/
-function node_type_get_clean_name(NodeType $node_type) {
- return check_plain($node_type->label());
+function node_type_get_clean_name($node_type) {
+ return check_plain($node_type->name);
}
/**
@@ -482,14 +487,12 @@ function node_type_get_clean_name(NodeType $node_type) {
* @return
* The node type description.
*/
-function node_type_get_description(NodeType $node_type) {
+function node_type_get_description($node_type) {
return $node_type->description;
}
/**
* Updates the cache of node types.
- *
- * @see _node_types_build()
*/
function node_types_rebuild() {
entity_info_cache_clear();
@@ -505,7 +508,11 @@ function node_types_rebuild() {
* A node type object or FALSE if $name does not exist.
*/
function node_type_load($name) {
- return entity_load('node_type', $name);
+
+ if ($type = config('node.type.' . $name)->get()) {
+ return (object) $type;
+ }
+ return FALSE;
}
/**
diff --git a/core/modules/poll/config/node.type.poll.yml b/core/modules/poll/config/node.type.poll.yml
new file mode 100644
index 0000000..254736e
--- /dev/null
+++ b/core/modules/poll/config/node.type.poll.yml
@@ -0,0 +1,12 @@
+type: poll
+name: 'Poll'
+base: poll
+module: poll
+description: 'A poll is a question with a set of possible responses. A poll, once created, automatically provides a simple running count of the number of votes received for each response.'
+help: ''
+custom: '1'
+modified: '0'
+locked: '0'
+disabled: '0'
+has_title: '1'
+title_label: Question
diff --git a/core/modules/poll/poll.install b/core/modules/poll/poll.install
index 75896bb..e343eaa 100644
--- a/core/modules/poll/poll.install
+++ b/core/modules/poll/poll.install
@@ -147,3 +147,21 @@ function poll_schema() {
return $schema;
}
+
+/**
+ * Implements hook_enable().
+ */
+function poll_enable() {
+ $poll = entity_load('node_type', 'poll');
+ $poll->disabled = FALSE;
+ $poll->save();
+}
+
+/**
+ * Implements hook_disable().
+ */
+function poll_disable() {
+ $poll = entity_load('node_type', 'poll');
+ $poll->disabled = TRUE;
+ $poll->save();
+}
diff --git a/core/modules/poll/poll.module b/core/modules/poll/poll.module
index d3f8d3a..50fbb79 100644
--- a/core/modules/poll/poll.module
+++ b/core/modules/poll/poll.module
@@ -175,21 +175,6 @@ function poll_cron() {
}
/**
- * Implements hook_node_info().
- */
-function poll_node_info() {
- return array(
- 'poll' => array(
- 'name' => t('Poll'),
- 'base' => 'poll',
- 'description' => t('A poll is a question with a set of possible responses. A poll, once created, automatically provides a simple running count of the number of votes received for each response.'),
- 'title_label' => t('Question'),
- 'has_body' => FALSE,
- )
- );
-}
-
-/**
* Implements hook_field_extra_fields().
*/
function poll_field_extra_fields() {
diff --git a/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php b/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php
index 187c386..7e2749d 100644
--- a/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php
+++ b/core/modules/rest/lib/Drupal/rest/Tests/DeleteTest.php
@@ -112,6 +112,8 @@ protected function entityCreate($entity_type) {
return entity_create('node', array('title' => $this->randomString()));
case 'user':
return entity_create('user', array('name' => $this->randomName()));
+ case 'node_type':
+ return entity_create('node_type', array('type' => 'article', 'name' => $this->randomName()));
default:
return entity_create($entity_type, array());
}
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 7d14ca0..1a3311a 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -325,6 +325,7 @@ protected function drupalCreateContentType($settings = array()) {
$type = $forced + $settings + $defaults;
$type = (object) $type;
+ $type = entity_create('node_type', (array) $type);
$saved_type = node_type_save($type);
node_types_rebuild();
menu_router_rebuild();
diff --git a/core/profiles/standard/standard.install b/core/profiles/standard/standard.install
index b4dc761..9cbfa2c 100644
--- a/core/profiles/standard/standard.install
+++ b/core/profiles/standard/standard.install
@@ -204,6 +204,7 @@ function standard_install() {
foreach ($types as $type) {
$type = node_type_set_defaults($type);
+ $type = entity_create('node_type', (array) $type);
node_type_save($type);
node_add_body_field($type);
}