2009-08-21 07:50:08 +00:00
|
|
|
<?php
|
2012-02-29 21:19:26 +00:00
|
|
|
/**
|
|
|
|
* @file
|
2012-10-05 16:11:15 +00:00
|
|
|
* Install, update and uninstall functions for the standard installation profile.
|
2012-02-29 21:19:26 +00:00
|
|
|
*/
|
2009-08-21 07:50:08 +00:00
|
|
|
|
2014-03-10 12:25:21 +00:00
|
|
|
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
|
2014-12-10 20:18:13 +00:00
|
|
|
use Drupal\user\Entity\User;
|
2015-03-14 21:50:47 +00:00
|
|
|
use Drupal\user\RoleInterface;
|
2014-03-10 12:25:21 +00:00
|
|
|
|
2009-08-21 07:50:08 +00:00
|
|
|
/**
|
2009-12-04 16:49:48 +00:00
|
|
|
* Implements hook_install().
|
2009-08-21 07:50:08 +00:00
|
|
|
*
|
|
|
|
* Perform actions to set up the site for this profile.
|
2012-02-29 21:19:26 +00:00
|
|
|
*
|
|
|
|
* @see system_install()
|
2009-08-21 07:50:08 +00:00
|
|
|
*/
|
2010-01-04 23:08:34 +00:00
|
|
|
function standard_install() {
|
2012-01-08 07:14:15 +00:00
|
|
|
// Set front page to "node".
|
2015-06-29 17:15:19 +00:00
|
|
|
\Drupal::configFactory()->getEditable('system.site')->set('page.front', '/node')->save(TRUE);
|
2012-01-08 07:14:15 +00:00
|
|
|
|
2010-05-27 12:29:39 +00:00
|
|
|
// Allow visitor account creation with administrative approval.
|
2015-01-16 10:43:35 +00:00
|
|
|
$user_settings = \Drupal::configFactory()->getEditable('user.settings');
|
2015-05-05 10:47:16 +00:00
|
|
|
$user_settings->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save(TRUE);
|
2010-05-27 12:29:39 +00:00
|
|
|
|
2009-08-27 20:25:29 +00:00
|
|
|
// Enable default permissions for system roles.
|
2015-03-14 21:50:47 +00:00
|
|
|
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access comments'));
|
|
|
|
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access comments', 'post comments', 'skip comment approval'));
|
2009-08-27 20:25:29 +00:00
|
|
|
|
2010-05-16 10:41:04 +00:00
|
|
|
// Assign user 1 the "administrator" role.
|
2014-12-10 20:18:13 +00:00
|
|
|
$user = User::load(1);
|
|
|
|
$user->roles[] = 'administrator';
|
|
|
|
$user->save();
|
2010-05-16 10:41:04 +00:00
|
|
|
|
2014-07-30 12:02:58 +00:00
|
|
|
// Enable the Contact link in the footer menu.
|
2014-07-30 12:04:04 +00:00
|
|
|
/** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
|
|
|
|
$menu_link_manager = \Drupal::service('plugin.manager.menu.link');
|
2015-05-05 10:47:16 +00:00
|
|
|
$menu_link_manager->updateDefinition('contact.site_page', array('enabled' => TRUE));
|
2014-07-30 12:04:04 +00:00
|
|
|
|
2015-03-14 21:50:47 +00:00
|
|
|
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access site-wide contact form'));
|
|
|
|
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access site-wide contact form'));
|
2012-11-20 11:36:51 +00:00
|
|
|
|
2014-06-09 23:13:41 +00:00
|
|
|
// Allow authenticated users to use shortcuts.
|
2015-03-14 21:50:47 +00:00
|
|
|
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access shortcuts'));
|
2014-06-09 23:13:41 +00:00
|
|
|
|
2012-09-05 03:13:17 +00:00
|
|
|
// Populate the default shortcut set.
|
2013-12-15 09:51:10 +00:00
|
|
|
$shortcut = entity_create('shortcut', array(
|
2013-12-15 16:04:46 +00:00
|
|
|
'shortcut_set' => 'default',
|
2013-12-15 09:51:10 +00:00
|
|
|
'title' => t('Add content'),
|
2012-09-05 03:13:17 +00:00
|
|
|
'weight' => -20,
|
2015-02-22 23:59:55 +00:00
|
|
|
'link' => array('uri' => 'internal:/node/add'),
|
2013-02-08 23:55:25 +00:00
|
|
|
));
|
2013-12-15 09:51:10 +00:00
|
|
|
$shortcut->save();
|
2013-02-08 23:55:25 +00:00
|
|
|
|
2013-12-15 09:51:10 +00:00
|
|
|
$shortcut = entity_create('shortcut', array(
|
2013-12-15 16:04:46 +00:00
|
|
|
'shortcut_set' => 'default',
|
2013-12-15 09:51:10 +00:00
|
|
|
'title' => t('All content'),
|
2012-09-05 03:13:17 +00:00
|
|
|
'weight' => -19,
|
2015-02-22 23:59:55 +00:00
|
|
|
'link' => array('uri' => 'internal:/admin/content'),
|
2013-02-08 23:55:25 +00:00
|
|
|
));
|
2013-12-15 09:51:10 +00:00
|
|
|
$shortcut->save();
|
2012-09-05 03:13:17 +00:00
|
|
|
|
2009-08-21 07:50:08 +00:00
|
|
|
// Enable the admin theme.
|
2015-05-05 10:47:16 +00:00
|
|
|
\Drupal::configFactory()->getEditable('node.settings')->set('use_admin_theme', TRUE)->save(TRUE);
|
2009-08-21 07:50:08 +00:00
|
|
|
}
|