static function EventType::courierContextCC in RNG - Events and Registrations 8
Create or clean up courier_context if none exist for an entity type.
Parameters
string $entity_type: Entity type of the event type.
string $operation: An operation: 'create' or 'delete'.
Overrides EventTypeInterface::courierContextCC
2 calls to EventType::courierContextCC()
- EventType::postDelete in src/
Entity/ EventType.php - Acts on deleted entities before the delete hook is invoked.
- EventType::preSave in src/
Entity/ EventType.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ EventType.php, line 314
Class
- EventType
- Defines the event type entity.
Namespace
Drupal\rng\EntityCode
static function courierContextCC($entity_type, $operation) {
$event_types = \Drupal::service('rng.event_manager')
->eventTypeWithEntityType($entity_type);
if (!count($event_types)) {
$courier_context = CourierContext::load('rng_registration_' . $entity_type);
if ($courier_context) {
if ($operation == 'delete') {
$courier_context
->delete();
}
}
else {
if ($operation == 'create') {
$entity_type_info = \Drupal::entityTypeManager()
->getDefinition($entity_type);
$courier_context = CourierContext::create([
'label' => t('Event (@entity_type): Registration', [
'@entity_type' => $entity_type_info
->getLabel(),
]),
'id' => 'rng_registration_' . $entity_type,
'tokens' => [
$entity_type,
'registration',
],
]);
$courier_context
->save();
}
}
}
}