function opigno_calendar_event_opigno_calendar_event_type_insert in Opigno calendar event 3.x
Same name and namespace in other branches
- 8 opigno_calendar_event.module \opigno_calendar_event_opigno_calendar_event_type_insert()
Implements hook_entity_bundle_create().
Throws
\Drupal\Component\Plugin\Exception\PluginNotFoundException
File
- ./
opigno_calendar_event.module, line 46 - Main file for the "Calendar event" module.
Code
function opigno_calendar_event_opigno_calendar_event_type_insert(ConfigEntityInterface $type) {
// @todo Clean up this once
// https://www.drupal.org/project/drupal/issues/2346013 is fixed.
$bundle = $type
->id();
$entity_type_id = CalendarEventInterface::ENTITY_TYPE_ID;
$entity_type = \Drupal::entityTypeManager()
->getDefinition($entity_type_id);
$update_manager = \Drupal::entityDefinitionUpdateManager();
/** @var \Drupal\Core\Field\FieldStorageDefinitionInterface $storage_definition */
foreach (CalendarEvent::bundleFieldDefinitions($entity_type, $bundle, []) as $storage_definition) {
$update_manager
->installFieldStorageDefinition($storage_definition
->getName(), $entity_type_id, 'opigno_calendar_event', $storage_definition);
}
}