niobi-8.x-2.0-alpha4/modules/niobi_pages/niobi_pages.install
modules/niobi_pages/niobi_pages.install
<?php
/**
* @file
*/
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
/**
* Implements hook_install().
*/
function niobi_pages_install() {
\Drupal::service('config.installer')->installDefaultConfig('module', 'niobi_pages');
$role_objects = Role::loadMultiple(['anonymous', 'authenticated']);
foreach ($role_objects as $role_object) {
$role_object->grantPermission('view niobi pages');
$role_object->save();
}
$site_config = \Drupal::configFactory()->getEditable('system.site');
$site_settings = $site_config->getOriginal('page');
$site_settings['front'] = '/dashboard';
$site_config->set('page', $site_settings)->save();
\Drupal::messenger()->addMessage('Niobi Pages has been installed.');
}
/**
* Implements hook_uninstall().
*/
function niobi_pages_uninstall() {
\Drupal::service('config.manager')->uninstall('module', 'niobi_pages');
// Set the homepage to something that shouldn't return a 404.
$site_config = \Drupal::configFactory()->getEditable('system.site');
$site_settings = $site_config->getOriginal('page');
$site_settings['front'] = '/user';
$site_config->set('page', $site_settings)->save();
}