1 node.module | node_config_create_validate(Config $staging_config, $all_changes) |
Implements hook_config_create_validate().
File
- core/
modules/ node/ node.module, line 3653 - The core module that allows content to be submitted to the site.
Code
function node_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.node.') === 0) {
list($node_type, $field_name) = explode('.', str_replace('field.instance.node.', '', $config_name));
// Check that the node type does or will exist.
$type_exists = (bool) node_type_get_type($node_type);
$type_created = !empty($all_changes['node.type.' . $node_type]);
if (!$type_exists && !$type_created) {
throw new ConfigValidateException(t('The field "@name" cannot be added because the node type "@type" does not exist.', array('@name' => $field_name, '@type' => $node_type)));
}
}
}