You are here

function panopoly_install in Panopoly 8.2

Same name and namespace in other branches
  1. 7 panopoly.install \panopoly_install()

Implements hook_install().

Perform actions to set up the site for this profile.

See also

system_install()

File

./panopoly.install, line 39
Install, update and uninstall hooks.

Code

function panopoly_install() {

  // Assign user 1 the "administrator" role.
  $user = User::load(1);
  $user->roles[] = 'administrator';
  $user
    ->save();

  // Grant the 'use panopoly_search' permission to anonymous users by default.
  $role = Role::load(Role::ANONYMOUS_ID);
  $role
    ->grantPermission('use panopoly_search');
  $role
    ->save();

  // We install some menu links, so we have to rebuild the router, to ensure the
  // menu links are valid.
  \Drupal::service('router.builder')
    ->rebuildIfNeeded();

  // Populate the default shortcut set.
  $shortcut = Shortcut::create([
    'shortcut_set' => 'default',
    'title' => t('Add content'),
    'weight' => -20,
    'link' => [
      'uri' => 'internal:/node/add',
    ],
  ]);
  $shortcut
    ->save();
  $shortcut = Shortcut::create([
    'shortcut_set' => 'default',
    'title' => t('All content'),
    'weight' => -19,
    'link' => [
      'uri' => 'internal:/admin/content',
    ],
  ]);
  $shortcut
    ->save();
}