diff --git a/islandora.install b/islandora.install index f9eb1225..8eb5047f 100644 --- a/islandora.install +++ b/islandora.install @@ -174,3 +174,26 @@ function update_jsonld_included_namespaces() { ->warning("Could not find required jsonld.settings to add default RDF namespaces."); } } + +/** + * Switches homepage to a twig based version. + */ +function islandora_update_8007() { + reset_homepage(); +} + +/** + * Used by install and update_8007 to reset homepage to use twig. + */ +function reset_homepage() { + $frontPage = \Drupal::configFactory()->get('system.site')->get('page.front'); + $original_template = \Drupal::service('file_system')->realpath(\Drupal::service('module_handler')->getModule('islandora')->getPath()); + $theme_templates = DRUPAL_ROOT . '/' . drupal_get_path('theme', \Drupal::config('system.theme')->get('default')) . '/templates'; + if (! file_exists($theme_templates . '/welcome.html.twig')) { + copy( $original_template . '/templates/welcome.html.twig', $theme_templates . '/welcome.html.twig'); + copy( $original_template . '/templates/welcome_base.html.twig', $theme_templates . '/welcome_base.html.twig'); + } + if ($frontPage != '/welcome') { + \Drupal::configFactory()->getEditable('system.site')->set('page.front', '/welcome')->save(); + } +}