social_page.install in Open Social 8.9
Same filename and directory in other branches
- 8 modules/social_features/social_page/social_page.install
- 8.2 modules/social_features/social_page/social_page.install
- 8.3 modules/social_features/social_page/social_page.install
- 8.4 modules/social_features/social_page/social_page.install
- 8.5 modules/social_features/social_page/social_page.install
- 8.6 modules/social_features/social_page/social_page.install
- 8.7 modules/social_features/social_page/social_page.install
- 8.8 modules/social_features/social_page/social_page.install
- 10.3.x modules/social_features/social_page/social_page.install
- 10.0.x modules/social_features/social_page/social_page.install
- 10.1.x modules/social_features/social_page/social_page.install
- 10.2.x modules/social_features/social_page/social_page.install
Install, update and uninstall functions for the social_page module.
File
modules/social_features/social_page/social_page.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the social_page module.
*/
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*
* Perform actions related to the installation of social_page.
*/
function social_page_install() {
// Set some default permissions.
_social_page_set_permissions();
}
/**
* Function to set permissions.
*/
function _social_page_set_permissions() {
$roles = Role::loadMultiple();
/** @var \Drupal\user\Entity\Role $role */
foreach ($roles as $role) {
if ($role
->id() === 'administrator') {
continue;
}
$permissions = _social_page_get_permissions($role
->id());
user_role_grant_permissions($role
->id(), $permissions);
}
}
/**
* Build the permissions.
*/
function _social_page_get_permissions($role) {
// Anonymous.
$permissions['anonymous'] = [
'view node.page.field_content_visibility:public content',
];
// Authenticated.
$permissions['authenticated'] = array_merge($permissions['anonymous'], [
'view node.page.field_content_visibility:community content',
]);
// Content manager.
$permissions['contentmanager'] = array_merge($permissions['authenticated'], [
'create page content',
'delete any page content',
'delete own page content',
'edit any page content',
'edit own page content',
'view page revisions',
'delete page revisions',
'revert page revisions',
'override page revision log entry',
'override page authored by option',
'override page published option',
'override page authored on option',
'override page promote to front page option',
'override page revision option',
'override page sticky option',
]);
// Site manager.
$permissions['sitemanager'] = array_merge($permissions['contentmanager'], [
'administer visibility settings',
]);
if (isset($permissions[$role])) {
return $permissions[$role];
}
return [];
}
/**
* Implements hook_update_dependencies().
*/
function social_page_update_dependencies() {
// New config changes should run after the update helper module is enabled.
$dependencies['social_page'][8801] = [
'social_core' => 8805,
];
return $dependencies;
}
/**
* Ensure the hero image field label is not visible.
*/
function social_page_update_8001() {
/** @var \Drupal\update_helper\Updater $updateHelper */
$updateHelper = \Drupal::service('update_helper.updater');
// Execute configuration update definitions with logging of success.
$updateHelper
->executeUpdate('social_page', 'social_page_update_8001');
// Output logged messages to related channel of update execution.
return $updateHelper
->logger()
->output();
}
/**
* Hide image label in teasers.
*/
function social_page_update_8002() {
/** @var \Drupal\update_helper\Updater $updateHelper */
$updateHelper = \Drupal::service('update_helper.updater');
// Execute configuration update definitions with logging of success.
$updateHelper
->executeUpdate('social_page', 'social_page_update_8002');
// Output logged messages to related channel of update execution.
return $updateHelper
->logger()
->output();
}
Functions
Name![]() |
Description |
---|---|
social_page_install | Implements hook_install(). |
social_page_update_8001 | Ensure the hero image field label is not visible. |
social_page_update_8002 | Hide image label in teasers. |
social_page_update_dependencies | Implements hook_update_dependencies(). |
_social_page_get_permissions | Build the permissions. |
_social_page_set_permissions | Function to set permissions. |