You are here

function node_type_example_install in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 node_type_example/node_type_example.install \node_type_example_install()

Implements hook_install().

We don't want users to be able to delete our locked_content_type content type. So therefore we have to tell Drupal that this is the case. This can't be done in the content type's configuration YAML file, so we have to do it in code, here.

Related topics

File

modules/node_type_example/node_type_example.install, line 18
Install file for node_type_example.

Code

function node_type_example_install() {

  // Do not allow the locked content type to be deleted.
  $locked = Drupal::state()
    ->get('node.type.locked');
  $locked['locked_content_type'] = 'locked_content_type';
  Drupal::state()
    ->set('node.type.locked', $locked);
}