public function EntityBundleListener::onBundleCreate

public EntityBundleListener::onBundleCreate($bundle, $entity_type_id)

Reacts to a bundle being created.

Parameters

string $bundle: The name of the bundle created.

string $entity_type_id: The entity type to which the bundle is bound; e.g. 'node' or 'user'.

Overrides EntityBundleListenerInterface::onBundleCreate

File

core/lib/Drupal/Core/Entity/EntityBundleListener.php, line 62

Class

EntityBundleListener
Reacts to entity bundle CRUD on behalf of the Entity system.

Namespace

Drupal\Core\Entity

Code

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]);
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Entity!EntityBundleListener.php/function/EntityBundleListener::onBundleCreate/8.1.x