Loading recurring_events.install +54 −0 Original line number Diff line number Diff line Loading @@ -595,3 +595,57 @@ function recurring_events_update_8012() { $field_storage_definition = $definition_manager->getFieldStorageDefinition('event_instances', 'eventseries'); $definition_manager->uninstallFieldStorageDefinition($field_storage_definition); } /** * Update any views that use old event instance relationship. */ function recurring_events_update_8013() { $config_factory = \Drupal::configFactory(); if (!$views = \Drupal\views\Views::getAllViews()) { return []; } $messages = []; foreach ($views as $view_id => $view) { $config = $config_factory->getEditable('views.view.' . $view_id); if (!$displays = $config->get('display')) { continue; } $changed = FALSE; foreach ($displays as $display_id => $display) { if (empty($display['display_options']['relationships'])) { continue; } foreach ($display['display_options']['relationships'] as $id => $relationship) { $table = $relationship['table'] ?? NULL; if ($table != 'eventseries__event_instances') { continue; } $relationship['table'] = 'eventseries_field_data'; if ($relationship['admin_label'] == 'Event Instance entity') { // Change label if it wasn't customized. $relationship['admin_label'] = 'Event Series Instances'; } unset($relationship['entity_field']); $displays[$display_id]['display_options']['relationships'][$id] = $relationship; $changed = TRUE; } } if ($changed) { $config->set('display', $displays); $config->save(TRUE); $messages[] = t('Updated view @id.', ['@id' => $view_id]); } } if (!empty($messages)) { return implode("</br> \n", $messages); } return t('No Recurring events views to update.'); } recurring_events.views.inc +17 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,23 @@ function recurring_events_views_data_alter(array &$data) { ], ]; $data['eventseries_field_data']['event_instances_target_id'] = [ 'title' => t('Event Instances'), 'help' => t('Display the event instances associated with the series'), 'relationship' => [ // Views name of the table being joined to from foo. 'base' => 'eventinstance_field_data', // Database field name in example_table for the join. 'base field' => 'eventseries_id', // Real database field name in foo for the join, to override // 'unique_dummy_name'. 'field' => 'id', // ID of relationship handler plugin to use. 'id' => 'standard', 'label' => t('Event Series Instances'), ], ]; $data['eventseries_field_data']['term_eventseries_tid_depth'] = [ 'help' => t('Display event series if it has the selected taxonomy terms, or children of the selected terms.'), 'real field' => 'id', Loading Loading
recurring_events.install +54 −0 Original line number Diff line number Diff line Loading @@ -595,3 +595,57 @@ function recurring_events_update_8012() { $field_storage_definition = $definition_manager->getFieldStorageDefinition('event_instances', 'eventseries'); $definition_manager->uninstallFieldStorageDefinition($field_storage_definition); } /** * Update any views that use old event instance relationship. */ function recurring_events_update_8013() { $config_factory = \Drupal::configFactory(); if (!$views = \Drupal\views\Views::getAllViews()) { return []; } $messages = []; foreach ($views as $view_id => $view) { $config = $config_factory->getEditable('views.view.' . $view_id); if (!$displays = $config->get('display')) { continue; } $changed = FALSE; foreach ($displays as $display_id => $display) { if (empty($display['display_options']['relationships'])) { continue; } foreach ($display['display_options']['relationships'] as $id => $relationship) { $table = $relationship['table'] ?? NULL; if ($table != 'eventseries__event_instances') { continue; } $relationship['table'] = 'eventseries_field_data'; if ($relationship['admin_label'] == 'Event Instance entity') { // Change label if it wasn't customized. $relationship['admin_label'] = 'Event Series Instances'; } unset($relationship['entity_field']); $displays[$display_id]['display_options']['relationships'][$id] = $relationship; $changed = TRUE; } } if ($changed) { $config->set('display', $displays); $config->save(TRUE); $messages[] = t('Updated view @id.', ['@id' => $view_id]); } } if (!empty($messages)) { return implode("</br> \n", $messages); } return t('No Recurring events views to update.'); }
recurring_events.views.inc +17 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,23 @@ function recurring_events_views_data_alter(array &$data) { ], ]; $data['eventseries_field_data']['event_instances_target_id'] = [ 'title' => t('Event Instances'), 'help' => t('Display the event instances associated with the series'), 'relationship' => [ // Views name of the table being joined to from foo. 'base' => 'eventinstance_field_data', // Database field name in example_table for the join. 'base field' => 'eventseries_id', // Real database field name in foo for the join, to override // 'unique_dummy_name'. 'field' => 'id', // ID of relationship handler plugin to use. 'id' => 'standard', 'label' => t('Event Series Instances'), ], ]; $data['eventseries_field_data']['term_eventseries_tid_depth'] = [ 'help' => t('Display event series if it has the selected taxonomy terms, or children of the selected terms.'), 'real field' => 'id', Loading