1 taxonomy.module | taxonomy_config_create_validate(Config $staging_config, $all_changes) |
Implements hook_config_create_validate()
Related topics
File
- core/
modules/ taxonomy/ taxonomy.module, line 2164 - Enables the organization of content into categories.
Code
function taxonomy_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, 'taxonomy.vocabulary.') === 0) {
list($vocabulary_name, $field_name) = explode('.', str_replace('taxonomy.vocabulary.', '', $config_name));
// Check that the vocabulary does or will exist.
$vocabulary_exists = (bool) taxonomy_vocabulary_load($vocabulary_name);
$vocabulary_created = $all_changes['taxonomy.vocabulary.' . $vocabulary_name];
if (!$vocabulary_exists && !$vocabulary_created) {
throw new ConfigValidateException(t('The field "@name" cannot be added because the vocabulary "@vocabulary" does not exist.', array('@name' => $field_name, '@vocabulary' => $vocabulary_name)));
}
}
}