Skip to content

Commit

Permalink
Commenting out some update hooks to get updates and config imports wo…
Browse files Browse the repository at this point in the history
…rking again
  • Loading branch information
ckoppenhaver committed Oct 6, 2021
1 parent 22ce5bc commit 9572eee
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 39 deletions.
46 changes: 24 additions & 22 deletions modules/wri_event/wri_event.install
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,33 @@
*/
function wri_event_update_8901() {
// Update the views.view.events view.
$config_factory = \Drupal::configFactory();
// $config_factory = \Drupal::configFactory();

// Load the view.
$view = $config_factory->getEditable('views.view.events');
// // Load the view.
// $view = $config_factory->getEditable('views.view.events');

// Go through each display on each view.
$displays = $view->get('display');
foreach ($displays as $display_name => $display) {
// // Go through each display on each view.
// $displays = $view->get('display');
// foreach ($displays as $display_name => $display) {

$base = "display.$display_name.display_options";
// Go through all the entity fields on each display and find ones currently using 'date' as the plugin.
if (!empty($display['display_options'])) {
// Make sure the comment is added.
$view->set($base . '.display_comment', 'This view is altered by the wri_event_views_query_alter function, which sets the order do "DESC" if the "View Past Events" option is chosen.');
}
if (!empty($display['display_options']['sorts']['field_date_time'])) {
// Make sure the sort is ASC.
// $base = "display.$display_name.display_options";
// // Go through all the entity fields on each display and find ones currently using 'date' as the plugin.
// if (!empty($display['display_options'])) {
// // Make sure the comment is added.
// $view->set($base . '.display_comment', 'This view is altered by the wri_event_views_query_alter function, which sets the order do "DESC" if the "View Past Events" option is chosen.');
// }
// if (!empty($display['display_options']['sorts']['field_date_time'])) {
// // Make sure the sort is ASC.

$view->set($base . '.sorts.field_date_time.order', 'ASC');
}
}
// $view->set($base . '.sorts.field_date_time.order', 'ASC');
// }
// }

$view->save(TRUE);
// Compose a message about what was done.
// Omitted in this example.
$message = 'Updated the Events view to sort past events DESC and future events ASC.';
return $message;
// $view->save(TRUE);
// // Compose a message about what was done.
// // Omitted in this example.
// $message = 'Updated the Events view to sort past events DESC and future events ASC.';
// return $message;

print 'Commenting out for now due to causing issue with config import.';
}
36 changes: 19 additions & 17 deletions modules/wri_search/wri_search.install
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@
* Adds the new Smart Topic index field and sets All Topic facets to use it.
*/
function wri_search_update_8901() {
$search_index = \Drupal::configFactory()->getEditable('search_api.index.sitewide');
$smart_topic_parent = [
'label' => 'Smart Topic',
'datasource_id' => 'entity:node',
'property_path' => 'smart_topic_parent',
'type' => 'integer',
'dependencies' => [
'module' => ['wri_search']
],
];
$search_index->set('field_settings.smart_topic_parent', $smart_topic_parent);
$search_index->save(TRUE);
// $search_index = \Drupal::configFactory()->getEditable('search_api.index.sitewide');
// $smart_topic_parent = [
// 'label' => 'Smart Topic',
// 'datasource_id' => 'entity:node',
// 'property_path' => 'smart_topic_parent',
// 'type' => 'integer',
// 'dependencies' => [
// 'module' => ['wri_search']
// ],
// ];
// $search_index->set('field_settings.smart_topic_parent', $smart_topic_parent);
// $search_index->save(TRUE);

foreach(['facets.facet.experts_all_topics', 'facets.facet.all_event_topics', 'facets.facet.all_topics'] as $config_name) {
$experts = \Drupal::configFactory()->getEditable($config_name);
$experts->set('field_identifier', 'smart_topic_parent');
$experts->save(TRUE);
}
// foreach(['facets.facet.experts_all_topics', 'facets.facet.all_event_topics', 'facets.facet.all_topics'] as $config_name) {
// $experts = \Drupal::configFactory()->getEditable($config_name);
// $experts->set('field_identifier', 'smart_topic_parent');
// $experts->save(TRUE);
// }

print 'Commenting out for now due to causing issue with config import.';
}

0 comments on commit 9572eee

Please sign in to comment.