Loading config/schema/recurring_events.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ recurring_events.eventseries.config: threshold_prevent_save: type: integer label: 'Prevent saving a series if too many instances are being created' creator_plugin: type: string label: 'The creator plugin used when creating event instances' recurring_events.eventinstance.config: type: config_object Loading recurring_events.api.php +21 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ * Custom hooks exposed by the recurring_events module. */ use Drupal\recurring_events\Entity\EventSeries; use Drupal\recurring_events\EventInstanceCreatorInterface; use Drupal\recurring_events\EventInstanceCreatorPluginManager; /** * Alter the time options available when creating an event series entity. * Loading Loading @@ -71,6 +75,23 @@ function hook_recurring_events_event_instance_alter(array &$event_instance = []) $event_instance['event_series_id'] = 12; } /** * Alter the active EventInstanceCreator plugin. * * @param Drupal\recurring_events\EventInstanceCreatorInterface $active_plugin * The active plugin to use. * @param Drupal\recurring_events\EventInstanceCreatorPluginManager $plugin_manager * The plugin manager to discover plugins. * @param Drupal\recurring_events\Entity\EventSeries $series * The event series for which we need to create instances. */ function hook_recurring_events_event_instance_creator_plugin_alter(EventInstanceCreatorInterface &$active_plugin, EventInstanceCreatorPluginManager $plugin_manager, EventSeries $series) { // If this is series #1 then use some-other-id plugin instead. if ($series->id() === 1) { $active_plugin = $plugin_manager->createInstance('some-other-id', []); } } /** * Alter the form config array after it has been generated. * Loading recurring_events.install +9 −0 Original line number Diff line number Diff line Loading @@ -649,3 +649,12 @@ function recurring_events_update_8013() { } return t('No Recurring events views to update.'); } /** * Set the default event instance plugin creator. */ function recurring_events_update_8014() { $config = \Drupal::configFactory()->getEditable('recurring_events.eventseries.config'); $config->set('creator_plugin', 'recurring_events_eventinstance_recreator'); $config->save(TRUE); } recurring_events.module +5 −2 Original line number Diff line number Diff line Loading @@ -219,8 +219,11 @@ function recurring_events_eventseries_update(EntityInterface $entity) { if ($date_changes) { if ($entity->isPublished() || !$moderated) { if ($entity->isDefaultTranslation()) { $creation_service->clearEventInstances($entity); $creation_service->createInstances($entity); $plugin_manager = \Drupal::service('plugin.manager.event_instance_creator'); $config = \Drupal::config('recurring_events.eventseries.config'); $active_plugin = $plugin_manager->createInstance($config->get('creator_plugin'), []); \Drupal::moduleHandler()->alter('recurring_events_event_instance_creator_plugin', $active_plugin, $plugin_manager, $entity); $active_plugin->processInstances($entity); } } // Get a fresh version of the series to get the updated instances. Loading recurring_events.services.yml +3 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,6 @@ services: recurring_events.event_creation_service: class: Drupal\recurring_events\EventCreationService arguments: ['@string_translation', '@database', '@logger.factory', '@messenger', '@plugin.manager.field.field_type', '@entity_field.manager', '@module_handler', '@entity_type.manager', '@keyvalue'] plugin.manager.event_instance_creator: class: Drupal\recurring_events\EventInstanceCreatorPluginManager parent: default_plugin_manager Loading
config/schema/recurring_events.schema.yml +3 −0 Original line number Diff line number Diff line Loading @@ -44,6 +44,9 @@ recurring_events.eventseries.config: threshold_prevent_save: type: integer label: 'Prevent saving a series if too many instances are being created' creator_plugin: type: string label: 'The creator plugin used when creating event instances' recurring_events.eventinstance.config: type: config_object Loading
recurring_events.api.php +21 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ * Custom hooks exposed by the recurring_events module. */ use Drupal\recurring_events\Entity\EventSeries; use Drupal\recurring_events\EventInstanceCreatorInterface; use Drupal\recurring_events\EventInstanceCreatorPluginManager; /** * Alter the time options available when creating an event series entity. * Loading Loading @@ -71,6 +75,23 @@ function hook_recurring_events_event_instance_alter(array &$event_instance = []) $event_instance['event_series_id'] = 12; } /** * Alter the active EventInstanceCreator plugin. * * @param Drupal\recurring_events\EventInstanceCreatorInterface $active_plugin * The active plugin to use. * @param Drupal\recurring_events\EventInstanceCreatorPluginManager $plugin_manager * The plugin manager to discover plugins. * @param Drupal\recurring_events\Entity\EventSeries $series * The event series for which we need to create instances. */ function hook_recurring_events_event_instance_creator_plugin_alter(EventInstanceCreatorInterface &$active_plugin, EventInstanceCreatorPluginManager $plugin_manager, EventSeries $series) { // If this is series #1 then use some-other-id plugin instead. if ($series->id() === 1) { $active_plugin = $plugin_manager->createInstance('some-other-id', []); } } /** * Alter the form config array after it has been generated. * Loading
recurring_events.install +9 −0 Original line number Diff line number Diff line Loading @@ -649,3 +649,12 @@ function recurring_events_update_8013() { } return t('No Recurring events views to update.'); } /** * Set the default event instance plugin creator. */ function recurring_events_update_8014() { $config = \Drupal::configFactory()->getEditable('recurring_events.eventseries.config'); $config->set('creator_plugin', 'recurring_events_eventinstance_recreator'); $config->save(TRUE); }
recurring_events.module +5 −2 Original line number Diff line number Diff line Loading @@ -219,8 +219,11 @@ function recurring_events_eventseries_update(EntityInterface $entity) { if ($date_changes) { if ($entity->isPublished() || !$moderated) { if ($entity->isDefaultTranslation()) { $creation_service->clearEventInstances($entity); $creation_service->createInstances($entity); $plugin_manager = \Drupal::service('plugin.manager.event_instance_creator'); $config = \Drupal::config('recurring_events.eventseries.config'); $active_plugin = $plugin_manager->createInstance($config->get('creator_plugin'), []); \Drupal::moduleHandler()->alter('recurring_events_event_instance_creator_plugin', $active_plugin, $plugin_manager, $entity); $active_plugin->processInstances($entity); } } // Get a fresh version of the series to get the updated instances. Loading
recurring_events.services.yml +3 −0 Original line number Diff line number Diff line Loading @@ -7,3 +7,6 @@ services: recurring_events.event_creation_service: class: Drupal\recurring_events\EventCreationService arguments: ['@string_translation', '@database', '@logger.factory', '@messenger', '@plugin.manager.field.field_type', '@entity_field.manager', '@module_handler', '@entity_type.manager', '@keyvalue'] plugin.manager.event_instance_creator: class: Drupal\recurring_events\EventInstanceCreatorPluginManager parent: default_plugin_manager