You are here

function quiz_install in Quiz 8.4

Same name and namespace in other branches
  1. 8.6 quiz.install \quiz_install()
  2. 8.5 quiz.install \quiz_install()
  3. 5.2 quiz.install \quiz_install()
  4. 5 quiz.install \quiz_install()
  5. 6.6 quiz.install \quiz_install()
  6. 6.2 quiz.install \quiz_install()
  7. 6.3 quiz.install \quiz_install()
  8. 6.4 quiz.install \quiz_install()
  9. 6.5 quiz.install \quiz_install()
  10. 7.6 quiz.install \quiz_install()
  11. 7 quiz.install \quiz_install()
  12. 7.4 quiz.install \quiz_install()
  13. 7.5 quiz.install \quiz_install()
  14. 6.x quiz.install \quiz_install()

Implements hook_install().

File

./quiz.install, line 12
Quiz install schema for installing the quiz module

Code

function quiz_install() {

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

  // Resets the cached information about entity types.
  // Equivalent to D7 node_types_rebuild();
  entity_info_cache_clear();

  // Clear the node type cache, so the new type appears.

  //\Drupal::cache()->deleteTags(array('node_types' => TRUE));

  // List all available node types.
  $types = node_type_get_types();

  // Adds the default body field to a node type quiz.
  node_add_body_field($types['quiz']);

  //TODO: Convert variable_set() to D8 config system as defined in quiz.settings.yml.
  drupal_set_message(t('Quiz module has been enabled. To !create_a_quiz go to Create Content -> Quiz.', array(
    '!create_a_quiz' => l(t('create a quiz'), 'node/add/quiz'),
  )));
}