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:
hook_node_type_insert()hook_node_type_update()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();
Comments
Any documentation or examples?
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.
created some documentation
I've created some documentation, feel free to comment.
https://drupal.org/node/2087879
Very helpful
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.
Example lives in Examples For
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...
HOW TO Generate YAML For A Content Type
admin/structure/types/add. Let's call it 'Nifty Content Type'.sites/default/files/config_[some hex codes]/active/. You'll see a file callednode.type.nifty_content_type.yml.config/directory.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.