1 comment.module comment_config_create_validate(Config $staging_config, $all_changes)

Implements hook_config_create_validate()

File

core/modules/comment/comment.module, line 1473
Enables users to comment on published content.

Code

function comment_config_create_validate(Config $staging_config, $all_changes) {
  $config_name = $staging_config->getName();

  // Ensure entity types and bundles exist or will be imported.
  if (strpos($config_name, 'field.instance.comment.') === 0) {
    list($node_type, $field_name) = explode('.', str_replace('field.instance.comment.', '', $config_name));
    $node_type = str_replace('comment_node_', '', $node_type);

    // Check that the node type does or will exist.
    $type_exists = (bool) node_type_get_type($node_type);
    $type_created = $all_changes['node.type.' . $node_type];
    if (!$type_exists && !$type_created) {
      throw new ConfigValidateException(t('The comment field "@name" cannot be added because the node type "@type" does not exist.', array('@name' => $field_name, '@type' => $node_type)));
    }
  }
}