Skip to content
Snippets Groups Projects
Commit feb3804e authored by Rajab Natshah's avatar Rajab Natshah
Browse files

Issue #3188641: Change the set front page to /node process from using static...

Issue #3188641: Change the set front page to /node process from using static node id to front page path by the alias
parent 9c333dd2
No related branches found
No related tags found
No related merge requests found
......@@ -14,6 +14,7 @@ use Drupal\varbase\Form\AssemblerForm;
use Drupal\varbase\Form\DevelopmentToolsAssemblerForm;
use Drupal\varbase\Entity\VarbaseEntityDefinitionUpdateManager;
use Drupal\node\Entity\Node;
use Drupal\path_alias\Entity\PathAlias;
/**
* Implements hook_form_FORM_ID_alter() for install_configure_form().
......@@ -528,6 +529,35 @@ function varbase_after_install_finished(array &$install_state) {
// * Rebuild the menu router based on all rebuilt data.
drupal_flush_all_caches();
// Set front page to "/node".
// Issue #3188641: Change the set front page to "/node" process from
// using static node id to front page path by the alias.
// https://www.drupal.org/project/varbase_core/issues/3188641
try {
$path_alias_query = \Drupal::entityQuery('path_alias');
$path_alias_query->condition('alias', '/node', '=');
$alias_ids = $path_alias_query->execute();
if (count($alias_ids) > 0) {
foreach ($alias_ids as $alias_id) {
if (!(end($alias_ids) == $alias_id)) {
$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());
}
global $base_url;
// After install direction.
......
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