Change record status: 
Project: 
Introduced in branch: 
8.x
Introduced in version: 
8.0-ALPHA3
Description: 

As a part of #1802750: [Meta] Convert configurable data to ConfigEntity system

The {node_type} table is no longer installed on Drupal 8 and a new node_type config entity is used instead. The table is preserved in installations upgraded from earlier versions of Drupal to allow contrib modules to migrate their data.

The prefix is node.type., one example is shipped with book module in node.type.book.yml:

type: book
name: 'Book page'
description: '<em>Books</em> have a built-in hierarchical navigation. Use for handbooks or tutorials.'
help: ''
has_title: '1'
title_label: Title
settings:
  node:
    preview: '1'
    options:
      status: status
      # Not promoted to front page.
      promote: '0'
      sticky: '0'
      revision: '0'
    submitted: '1'
status: '1'
langcode: en

To disable deletion and renaming of this content type (also known as "locking") developers need to add the node type to a special key in the state subsystem called node.type.locked:

  // Do not allow to delete the forum node type.
  $locked = Drupal::state()->get('node.type.locked');
  $locked['forum'] = 'forum';
  Drupal::state()->set('node.type.locked', $locked);

The following functions have changed:

  1. hook_node_type_insert()
  2. hook_node_type_update()
  3. hook_node_type_delete()

These now have a \Drupal\node\NodeTypeInterface object as argument.

hook_node_info() is removed in favour of config files.

The node pseudo-hooks (like hook_load(), hook_delete(), hook_insert(), hook_prepare(), hook_update(), hook_validate(), hook_view()) and functions invoking them: node_hook() and node_invoke() are removed. Modules should move their implementations into the corresponding hook_node_*() hooks and use hook_form_alter*() to modify node forms.

node_type_save() and node_type_delete() are removed. Use the following instead:

//node_type_save($info)
$info = node_type_load('article');
$info->save();
//node_type_delete($name)
$info = node_type_load('article');
$info->delete();
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

chris_hall_hu_cheng’s picture

I want to use this but don't know for example how to generate UUID for my content type.

I will add links if I find them but grateful for any pointers.

Anonymous’s picture

I've created some documentation, feel free to comment.

https://drupal.org/node/2087879

chris_hall_hu_cheng’s picture

I worked it out in the end but your documentation would have saved me a bit of time, so I am sure it will help others.

Mile23’s picture

Example lives in Examples For Developers project as node_type_example module. Browse the code here: http://drupalcode.org/project/examples.git/tree/refs/heads/8.x-1.x:/node...

Mile23’s picture

  1. Install Drupal 8.
  2. Create a new content type at admin/structure/types/add. Let's call it 'Nifty Content Type'.
  3. Look in sites/default/files/config_[some hex codes]/active/. You'll see a file called node.type.nifty_content_type.yml.
  4. Copy or move that file to your module's config/ directory.
  5. You are done. Contemplate on how SUPER SCARY Drupal 8 is!!!!

Update: You now have to export the config and dig through it for your node type and any fields you attached. Also core.entity_form_display.* in order to control which fields appear on the edit form.