taxonomy_permissions.install in Taxonomy Permissions 8
Same filename and directory in other branches
Install, update and uninstall functions for the taxonomy_permissions module.
File
taxonomy_permissions.installView 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
Name | Description |
---|---|
taxonomy_permissions_install | Implements hook_install(). |