You are here

function social_profile_update_8802 in Open Social 10.3.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_profile/social_profile.install \social_profile_update_8802()
  2. 8.8 modules/social_features/social_profile/social_profile.install \social_profile_update_8802()
  3. 10.0.x modules/social_features/social_profile/social_profile.install \social_profile_update_8802()
  4. 10.1.x modules/social_features/social_profile/social_profile.install \social_profile_update_8802()
  5. 10.2.x modules/social_features/social_profile/social_profile.install \social_profile_update_8802()

Update social_profile.settings config & permissions for authenticated role.

File

modules/social_features/social_profile/social_profile.install, line 410
Install, update and uninstall functions for the social_profile module.

Code

function social_profile_update_8802(&$sandbox) {
  $config = \Drupal::configFactory()
    ->getEditable('social_profile.settings');
  $config
    ->set('social_profile_show_language', TRUE);
  $config
    ->save();

  // Add permission to view profile language for authenticated role.
  $roles = Role::loadMultiple();
  $permissions = [
    'view profile language',
  ];

  /** @var \Drupal\user\Entity\Role $role */
  foreach ($roles as $role) {
    if (in_array($role
      ->id(), [
      'sitemanager',
      'contentmanager',
    ])) {
      user_role_grant_permissions($role
        ->id(), $permissions);
    }
  }
}