social_follow_content.install in Open Social 10.1.x
Same filename and directory in other branches
- 8.9 modules/social_features/social_follow_content/social_follow_content.install
- 8 modules/social_features/social_follow_content/social_follow_content.install
- 8.2 modules/social_features/social_follow_content/social_follow_content.install
- 8.3 modules/social_features/social_follow_content/social_follow_content.install
- 8.4 modules/social_features/social_follow_content/social_follow_content.install
- 8.5 modules/social_features/social_follow_content/social_follow_content.install
- 8.6 modules/social_features/social_follow_content/social_follow_content.install
- 8.7 modules/social_features/social_follow_content/social_follow_content.install
- 8.8 modules/social_features/social_follow_content/social_follow_content.install
- 10.3.x modules/social_features/social_follow_content/social_follow_content.install
- 10.0.x modules/social_features/social_follow_content/social_follow_content.install
- 10.2.x modules/social_features/social_follow_content/social_follow_content.install
Install, update and uninstall functions for the social_follow_content module.
File
modules/social_features/social_follow_content/social_follow_content.installView source
<?php
/**
* @file
* Install, update and uninstall functions for the social_follow_content module.
*/
use Drupal\user\Entity\Role;
/**
* Implements hook_install().
*
* Perform actions related to the installation of social_follow_content.
*/
function social_follow_content_install() {
// Set some default permissions.
_social_follow_content_set_permissions();
}
/**
* Function to set permissions.
*/
function _social_follow_content_set_permissions() {
$roles = Role::loadMultiple();
/** @var \Drupal\user\Entity\Role $role */
foreach ($roles as $role) {
if ($role
->id() === 'administrator') {
continue;
}
$permissions = _social_follow_content_get_permissions($role
->id());
if (!empty($permissions)) {
user_role_grant_permissions($role
->id(), $permissions);
}
}
}
/**
* Build permissions.
*
* @param string $role
* The role.
*
* @return array
* Returns an array containing the permissions.
*/
function _social_follow_content_get_permissions($role) {
// Anonymous.
$permissions['anonymous'] = [];
// Authenticated.
$permissions['authenticated'] = array_merge($permissions['anonymous'], [
'flag follow_content',
'unflag follow_content',
]);
// Content manager.
$permissions['contentmanager'] = array_merge($permissions['authenticated'], []);
// Site manager.
$permissions['sitemanager'] = array_merge($permissions['contentmanager'], []);
if (isset($permissions[$role])) {
return $permissions[$role];
}
return [];
}
/**
* Implements hook_update_dependencies().
*/
function social_follow_content_update_dependencies() {
// New config changes should run after the Update Helper module is enabled.
$dependencies['social_follow_content'][8801] = [
'social_core' => 8805,
];
return $dependencies;
}
/**
* Remove follow content button from Topic small teasers.
*/
function social_follow_content_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_follow_content', 'social_follow_content_update_8001');
// Output logged messages to related channel of update execution.
return $updateHelper
->logger()
->output();
}Functions
|
Name |
Description |
|---|---|
| social_follow_content_install | Implements hook_install(). |
| social_follow_content_update_8001 | Remove follow content button from Topic small teasers. |
| social_follow_content_update_dependencies | Implements hook_update_dependencies(). |
| _social_follow_content_get_permissions | Build permissions. |
| _social_follow_content_set_permissions | Function to set permissions. |