You are here

taxonomy_permissions.install in Taxonomy Permissions 8

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

Install, update and uninstall functions for the taxonomy_permissions module.

File

taxonomy_permissions.install
View source
<?php

/**
 * @file
 * Install, update and uninstall functions for the taxonomy_permissions module.
 */
use Drupal\Core\Session\AccountInterface;
use Drupal\taxonomy\Entity\Vocabulary;

/**
 * Implements hook_install().
 */
function taxonomy_permissions_install() {

  // Give 'view terms' access to all vocabularies to all users to avoid
  // surprises upon installation.
  $perms = [];
  $vocabularies = Vocabulary::loadMultiple();
  foreach ($vocabularies as $id => $vocabulary) {
    $perms[] = 'view terms in ' . $id;
  }
  if ($perms) {
    user_role_grant_permissions(AccountInterface::ANONYMOUS_ROLE, $perms);
    user_role_grant_permissions(AccountInterface::AUTHENTICATED_ROLE, $perms);
  }
}

Functions

Namesort descending Description
taxonomy_permissions_install Implements hook_install().