Skip to content

Commit

Permalink
Add post-update hook to install the new entities.
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-vessey committed Jul 12, 2023
1 parent 4df6b18 commit 09b5191
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions islandora_hocr.post_update.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* @file
* Post-update hooks.
*/

use Symfony\Component\Yaml\Yaml;

/**
* Install initial request handler and field type if they do not yet exist.
*/
function islandora_hocr_post_update_install_initial_entities() {
$ids = [
'search_api_solr.solr_field_type.islandora_hocr_und_7_0_0',
'search_api_solr.solr_request_handler.request_handler_select_islandora_hocr_7_0_0',
];

$config_dir = \Drupal::service('extension.list.module')->getPath('islandora_hocr') . '/config/install';

foreach ($ids as $id) {
$data = Yaml::parseFile("{$config_dir}/{$id}.yml");
$config = \Drupal::configFactory()->getEditable($id);
if ($config->isNew()) {
$config->initWithData($data)->save(TRUE);
}
}

}

0 comments on commit 09b5191

Please sign in to comment.