class Vocabulary
Same name in this branch
- main core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
- main core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
Same name and namespace in other branches
- 11.x core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary
- 11.x core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
- 11.x core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
- 10 core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary
- 10 core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
- 10 core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
- 9 core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary
- 9 core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
- 9 core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
- 8.9.x core/modules/taxonomy/src/Entity/Vocabulary.php \Drupal\taxonomy\Entity\Vocabulary
- 8.9.x core/modules/taxonomy/src/Plugin/migrate/source/d6/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d6\Vocabulary
- 8.9.x core/modules/taxonomy/src/Plugin/migrate/source/d7/Vocabulary.php \Drupal\taxonomy\Plugin\migrate\source\d7\Vocabulary
Defines the taxonomy vocabulary entity.
Attributes
#[ConfigEntityType(id: 'taxonomy_vocabulary', label: new TranslatableMarkup('Taxonomy vocabulary'), label_collection: new TranslatableMarkup('Taxonomy'), label_singular: new TranslatableMarkup('vocabulary'), label_plural: new TranslatableMarkup('vocabularies'), config_prefix: 'vocabulary', entity_keys: [
'id' => 'vid',
'label' => 'name',
'weight' => 'weight',
], handlers: [
'storage' => VocabularyStorage::class,
'list_builder' => VocabularyListBuilder::class,
'access' => VocabularyAccessControlHandler::class,
'form' => [
'default' => VocabularyForm::class,
'reset' => VocabularyResetForm::class,
'delete' => VocabularyDeleteForm::class,
'overview' => OverviewTerms::class,
],
'route_provider' => [
'html' => VocabularyRouteProvider::class,
'permissions' => EntityPermissionsRouteProvider::class,
],
], links: [
'add-form' => '/admin/structure/taxonomy/add',
'delete-form' => '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/delete',
'reset-form' => '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/reset',
'overview-form' => '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview',
'edit-form' => '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}',
'entity-permissions-form' => '/admin/structure/taxonomy/manage/{taxonomy_vocabulary}/overview/permissions',
'collection' => '/admin/structure/taxonomy',
], admin_permission: 'administer taxonomy', collection_permission: 'access taxonomy overview', bundle_of: 'taxonomy_term', label_count: [
'singular' => '@count vocabulary',
'plural' => '@count vocabularies',
], config_export: [
'name',
'vid',
'description',
'weight',
'new_revision',
])]
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements \Drupal\Core\Entity\EntityInterface uses \Drupal\Core\Cache\RefinableCacheableDependencyTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements \Drupal\Core\Config\Entity\ConfigEntityInterface uses \Drupal\Core\Plugin\PluginDependencyTrait, \Drupal\Core\Entity\SynchronizableEntityTrait extends \Drupal\Core\Entity\EntityBase
- class \Drupal\Core\Config\Entity\ConfigEntityBundleBase extends \Drupal\Core\Config\Entity\ConfigEntityBase
- class \Drupal\taxonomy\Entity\Vocabulary implements \Drupal\taxonomy\VocabularyInterface extends \Drupal\Core\Config\Entity\ConfigEntityBundleBase
- class \Drupal\Core\Config\Entity\ConfigEntityBundleBase extends \Drupal\Core\Config\Entity\ConfigEntityBase
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements \Drupal\Core\Config\Entity\ConfigEntityInterface uses \Drupal\Core\Plugin\PluginDependencyTrait, \Drupal\Core\Entity\SynchronizableEntityTrait extends \Drupal\Core\Entity\EntityBase
Expanded class hierarchy of Vocabulary
65 files declare their use of Vocabulary
- ArgumentSummaryTest.php in core/
modules/ views/ tests/ src/ Kernel/ Handler/ ArgumentSummaryTest.php - ArgumentValidatorTermNameTest.php in core/
modules/ taxonomy/ tests/ src/ Kernel/ Views/ ArgumentValidatorTermNameTest.php - CommentTokenReplaceTest.php in core/
modules/ comment/ tests/ src/ Functional/ CommentTokenReplaceTest.php - ConfigTranslationListUiTest.php in core/
modules/ config_translation/ tests/ src/ Functional/ ConfigTranslationListUiTest.php - ContentEntityTest.php in core/
modules/ migrate/ tests/ src/ Kernel/ Plugin/ source/ ContentEntityTest.php
17 string references to 'Vocabulary'
- drupal6.php in core/
modules/ migrate_drupal/ tests/ fixtures/ drupal6.php - A database agnostic dump for testing purposes.
- drupal6.php in core/
modules/ contact/ tests/ fixtures/ drupal6.php - A database agnostic dump for testing purposes.
- LanguageContentSettingsTaxonomyVocabulary::query in core/
modules/ language/ src/ Plugin/ migrate/ source/ d6/ LanguageContentSettingsTaxonomyVocabulary.php - Prepares query object to retrieve data from the source database.
- OverviewTerms::buildForm in core/
modules/ taxonomy/ src/ Form/ OverviewTerms.php - Form constructor.
- OverviewTerms::submitForm in core/
modules/ taxonomy/ src/ Form/ OverviewTerms.php - Form submission handler.
File
-
core/
modules/ taxonomy/ src/ Entity/ Vocabulary.php, line 23
Namespace
Drupal\taxonomy\EntityView source
class Vocabulary extends ConfigEntityBundleBase implements VocabularyInterface {
/**
* The taxonomy vocabulary ID.
*
* @var string
*/
protected $vid;
/**
* Name of the vocabulary.
*
* @var string
*/
protected $name;
/**
* Description of the vocabulary.
*
* @var string|null
*/
protected $description = NULL;
/**
* The weight of this vocabulary in relation to other vocabularies.
*
* @var int
*/
protected $weight = 0;
/**
* {@inheritdoc}
*/
public function id() {
return $this->vid;
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description ?? '';
}
/**
* The default revision setting for a vocabulary.
*
* @var bool
*/
protected $new_revision = FALSE;
/**
* {@inheritdoc}
*/
public static function preDelete(EntityStorageInterface $storage, array $entities) {
parent::preDelete($storage, $entities);
// Only load terms without a parent, child terms will get deleted too.
$term_storage = \Drupal::entityTypeManager()->getStorage('taxonomy_term');
$terms = $term_storage->loadMultiple($storage->getToplevelTids(array_keys($entities)));
$term_storage->delete($terms);
}
/**
* {@inheritdoc}
*/
public static function postDelete(EntityStorageInterface $storage, array $entities) {
parent::postDelete($storage, $entities);
// Reset caches.
$storage->resetCache(array_keys($entities));
if (reset($entities)->isSyncing()) {
return;
}
$vocabularies = [];
foreach ($entities as $vocabulary) {
$vocabularies[$vocabulary->id()] = $vocabulary->id();
}
// Load all Taxonomy module fields and delete those which use only this
// vocabulary.
$field_storages = \Drupal::entityTypeManager()->getStorage('field_storage_config')
->loadByProperties([
'module' => 'taxonomy',
]);
foreach ($field_storages as $field_storage) {
$modified_storage = FALSE;
// Term reference fields may reference terms from more than one
// vocabulary.
foreach ($field_storage->getSetting('allowed_values') as $key => $allowed_value) {
if (isset($vocabularies[$allowed_value['vocabulary']])) {
$allowed_values = $field_storage->getSetting('allowed_values');
unset($allowed_values[$key]);
$field_storage->setSetting('allowed_values', $allowed_values);
$modified_storage = TRUE;
}
}
if ($modified_storage) {
$allowed_values = $field_storage->getSetting('allowed_values');
if (empty($allowed_values)) {
$field_storage->delete();
}
else {
// Update the field definition with the new allowed values.
$field_storage->save();
}
}
}
}
/**
* {@inheritdoc}
*/
public function setNewRevision($new_revision) {
$this->new_revision = $new_revision;
}
/**
* {@inheritdoc}
*/
public function shouldCreateNewRevision() {
return $this->new_revision;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.