You are here

function _panopoly_demo_set_front_page in Panopoly 8.2

Helper to set the front page.

Parameters

string $path: The path for the front page.

2 calls to _panopoly_demo_set_front_page()
panopoly_demo_install in modules/panopoly/panopoly_demo/panopoly_demo.install
Implements hook_install().
panopoly_demo_uninstall in modules/panopoly/panopoly_demo/panopoly_demo.install
Implements hook_uninstall().

File

modules/panopoly/panopoly_demo/panopoly_demo.install, line 51
Install and update hooks for Panopoly Demo.

Code

function _panopoly_demo_set_front_page($path) {
  $site_config = \Drupal::configFactory()
    ->getEditable('system.site');
  $site_page_settings = $site_config
    ->get('page');

  // Only set the homepage if the site does not doesn't already have custom
  // front page.
  if (in_array($site_page_settings['front'], [
    '',
    '/user/login',
    '/node',
  ])) {
    $site_page_settings['front'] = $path;
    $site_config
      ->set('page', $site_page_settings);
    $site_config
      ->save();
  }
}