function event_group_event_insert in Event 8
Create a corresponding Event group when an event entity is created.
Parameters
\Drupal\Core\Entity\EntityInterface $entity:
File
- modules/
event_group/ event_group.module, line 232 - Enables Group functionality for the Event module.
Code
function event_group_event_insert(EventInterface $entity) {
$event_group_enabled = \Drupal::entityTypeManager()
->getStorage($entity
->getEntityType()
->getBundleEntityType())
->load($entity
->bundle())
->getThirdPartySetting('event_group', 'enabled', 0);
if ($event_group_enabled) {
$event_group = Group::create([
'type' => 'events',
'label' => $entity
->getName(),
]);
$event_group
->save();
}
}