You are here

webform_node.install in Webform 8.5

Same filename and directory in other branches
  1. 6.x modules/webform_node/webform_node.install

Install, update and uninstall functions for the webform node module.

File

modules/webform_node/webform_node.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the webform node module.
 */

/**
 * Implements hook_requirements().
 */
function webform_node_requirements($phase) {
  $requirements = [];

  // Throw error if Webform (webform) content type is already exists which will
  // happen during a D7 to D8 content migration.
  // @see https://www.drupal.org/node/2856599
  if ($phase === 'install') {
    $manager = \Drupal::entityTypeManager();
    if ($manager
      ->hasDefinition('node_type') && ($node_type = $manager
      ->getStorage('node_type')
      ->load('webform'))) {
      $requirements['webform_node'] = [
        'title' => t('Webform Node'),
        'value' => t('%title content type already exists', [
          '%title' => $node_type
            ->label(),
        ]),
        'description' => t('%title content type already exists, please delete the %title content type before installing the Webform node module.', [
          '%title' => $node_type
            ->label(),
        ]),
        'severity' => REQUIREMENT_ERROR,
      ];
    }
  }
  return $requirements;
}

Functions