Skip to content
Snippets Groups Projects
Commit 154858c4 authored by Shaimaa Natshah's avatar Shaimaa Natshah
Browse files

Issue #3344417 by Tasneem Natshah: Change the default front page from "/node" to "/home"

parent bffcf84a
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,8 @@ function webship_form_install_configure_form_alter(&$form, FormStateInterface $f
function webship_install_tasks_alter(&$tasks, $install_state) {
unset($tasks['install_select_language']);
unset($tasks['install_download_translation']);
$tasks['install_finished']['function'] = 'webship_after_install_finished';
}
/**
......@@ -34,3 +36,46 @@ function webship_preprocess_install_page(&$variables) {
// Webship has custom styling for the install page.
$variables['#attached']['library'][] = 'webship/install-page';
}
/**
* Webship after install finished.
*
* Set front page to "/home" after install.
*
* @param array $install_state
* The current install state.
*
* @return array
* A renderable array with a redirect header.
*/
function webship_after_install_finished(array &$install_state) {
// Set front page to "/home".
try {
$alias_ids = \Drupal::entityQuery('path_alias')
->accessCheck(FALSE)
->condition('alias', '/home', '=')
->execute();
if (count($alias_ids) > 0) {
foreach ($alias_ids as $alias_id) {
if (!(end($alias_ids))) {
$path_alias = PathAlias::load($alias_id);
$path_alias->delete();
}
else {
$page_front_path = PathAlias::load($alias_id)->getPath();
\Drupal::configFactory()->getEditable('system.site')
->set('page.front', $page_front_path)
->save();
}
}
}
}
catch (\Exception $e) {
\Drupal::messenger()->addError($e->getMessage());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment