entityTypeManager = $entity_type_manager; $this->entityTypeBundleInfo = $entity_type_bundle_info; $this->entityFieldManager = $entity_field_manager; $this->moduleHandler = $module_handler; } /** * {@inheritdoc} */ public function onBundleCreate($bundle, $entity_type_id) { $this->entityTypeBundleInfo->clearCachedBundles(); // Notify the entity storage. $storage = $this->entityTypeManager->getStorage($entity_type_id); if ($storage instanceof EntityBundleListenerInterface) { $storage->onBundleCreate($bundle, $entity_type_id); } // Invoke hook_entity_bundle_create() hook. $this->moduleHandler->invokeAll('entity_bundle_create', [$entity_type_id, $bundle]); $this->entityFieldManager->clearCachedFieldDefinitions(); } /** * {@inheritdoc} */ public function onBundleDelete($bundle, $entity_type_id) { $this->entityTypeBundleInfo->clearCachedBundles(); // Notify the entity storage. $storage = $this->entityTypeManager->getStorage($entity_type_id); if ($storage instanceof EntityBundleListenerInterface) { $storage->onBundleDelete($bundle, $entity_type_id); } // Invoke hook_entity_bundle_delete() hook. $this->moduleHandler->invokeAll('entity_bundle_delete', [$entity_type_id, $bundle]); $this->entityFieldManager->clearCachedFieldDefinitions(); } }