You are here

language_access.install in Language access 8

Same filename and directory in other branches
  1. 7 language_access.install

The install and update code for language_access.

File

language_access.install
View source
<?php

/**
 * @file
 * The install and update code for language_access.
 */
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;

/**
 * Implements hook_install().
 */
function language_access_install() {
  $default_language = \Drupal::languageManager()
    ->getDefaultLanguage();

  /** @var \Drupal\user\RoleInterface[] $roles */
  $roles = Role::loadMultiple([
    RoleInterface::ANONYMOUS_ID,
    RoleInterface::AUTHENTICATED_ID,
  ]);
  foreach ($roles as $role) {
    $role
      ->grantPermission('access language ' . $default_language
      ->getId())
      ->save();
  }
}

Functions

Namesort descending Description
language_access_install Implements hook_install().