genoring_distrib-1.0.0-alpha3/genoring_distrib.install
genoring_distrib.install
<?php
/**
* @file
* Install, update and uninstall functions for the profilename install profile.
*/
use Drupal\node\Entity\Node;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*
* @see system_install()
*/
function genoring_distrib_install() {
// First, do everything in standard profile.
include_once DRUPAL_ROOT . '/core/profiles/standard/standard.install';
standard_install();
// Create homepage.
$node = Node::create([
'type' => 'page',
'title' => 'Welcome to GenoRing',
'body' => [
'value' => 'This is the GenoRing site. You may now access to the <a href="/genoring/">GenoRing dashboard</a> if your are logged in as admin.',
'summary' => '',
'format' => 'full_html',
],
'uid' => 1,
'status' => TRUE,
'promote' => TRUE,
'sticky' => FALSE,
'path' => [
'alias' => '/home',
],
]);
$node->save();
// Create help page.
$node = Node::create([
'type' => 'page',
'title' => 'Help',
'body' => [
'value' => 'This is the main help page.',
'summary' => '',
'format' => 'full_html',
],
'uid' => 1,
'status' => TRUE,
'promote' => FALSE,
'sticky' => FALSE,
'path' => [
'alias' => '/help',
],
]);
$node->save();
// Create tools page.
$node = Node::create([
'type' => 'page',
'title' => 'Tools',
'body' => [
'value' => 'This is the available tool list with descriptions.',
'summary' => '',
'format' => 'full_html',
],
'uid' => 1,
'status' => TRUE,
'promote' => FALSE,
'sticky' => FALSE,
'path' => [
'alias' => '/tools',
],
]);
$node->save();
// Set default permissions.
$all_roles = Role::loadMultiple([
RoleInterface::ANONYMOUS_ID,
RoleInterface::AUTHENTICATED_ID
]);
$all_permissions = [
// 'use brapi',
];
foreach ($all_permissions as $permission) {
$all_roles[RoleInterface::AUTHENTICATED_ID]->grantPermission($permission);
$all_roles[RoleInterface::ANONYMOUS_ID]->grantPermission($permission);
}
$all_roles[RoleInterface::AUTHENTICATED_ID]->save();
$all_roles[RoleInterface::ANONYMOUS_ID]->save();
}
