public static function RngEventType::courierContextCC in RNG - Events and Registrations 8.2
Same name and namespace in other branches
- 3.x src/Entity/RngEventType.php \Drupal\rng\Entity\RngEventType::courierContextCC()
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 RngEventType::courierContextCC()
- RngEventType::postDelete in src/
Entity/ RngEventType.php - Acts on deleted entities before the delete hook is invoked.
- RngEventType::preSave in src/
Entity/ RngEventType.php - Acts on an entity before the presave hook is invoked.
File
- src/
Entity/ RngEventType.php, line 369
Class
- RngEventType
- Defines the event type entity.
Namespace
Drupal\rng\EntityCode
public 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();
}
}
}
}