public function EntityTraitManager::uninstallTrait in Commerce Core 8.2
Uninstalls the given trait for the given entity type and bundle.
Uninstalling a trait removes any fields that the trait provides from the given bundle.
Parameters
\Drupal\commerce\Plugin\Commerce\EntityTrait\EntityTraitInterface $trait: The trait.
string $entity_type_id: The entity type id.
string $bundle: The bundle.
Overrides EntityTraitManagerInterface::uninstallTrait
File
- src/
EntityTraitManager.php, line 126
Class
- EntityTraitManager
- Manages discovery and instantiation of entity trait plugins.
Namespace
Drupal\commerceCode
public function uninstallTrait(EntityTraitInterface $trait, $entity_type_id, $bundle) {
foreach ($trait
->buildFieldDefinitions() as $field_name => $field_definition) {
$field_definition
->setTargetEntityTypeId($entity_type_id);
$field_definition
->setTargetBundle($bundle);
$field_definition
->setName($field_name);
$this->configurableFieldManager
->deleteField($field_definition);
}
}