-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add post-update hook to install the new entities.
- Loading branch information
1 parent
4df6b18
commit 09b5191
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
||
} |