From d2a773a62516cc38a0d5bc8d82f6345d4ad49ea1 Mon Sep 17 00:00:00 2001 From: Jared Whiklo Date: Thu, 8 Jun 2017 09:37:12 -0500 Subject: [PATCH] Add hook_install for rest configuration (#65) --- islandora.install | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/islandora.install b/islandora.install index e900f2f6..6cd04214 100644 --- a/islandora.install +++ b/islandora.install @@ -40,3 +40,28 @@ function islandora_schema() { ]; return $schema; } + +/** + * Implements hook_install(). + */ +function islandora_install() { + if (\Drupal::moduleHandler()->moduleExists('rest')) { + $rest_resource_config_storage = \Drupal::service('entity_type.manager')->getStorage('rest_resource_config'); + $rest_resource_config = $rest_resource_config_storage->load('entity.node'); + + if ($rest_resource_config) { + $configuration = $rest_resource_config->get('configuration'); + + if (!in_array('jsonld', $configuration['formats'])) { + $configuration['formats'][] = 'jsonld'; + } + + if (!in_array('jwt_auth', $configuration['authentication'])) { + $configuration['authentication'][] = 'jwt_auth'; + } + + $rest_resource_config->set('configuration', $configuration); + $rest_resource_config->save(TRUE); + } + } +}