function thunder_taxonomy_update_8001 in Thunder 8.2
Grant term access permissions.
File
- modules/
thunder_taxonomy/ thunder_taxonomy.install, line 30 - Contains Thunder taxonomy install / uninstall hooks.
Code
function thunder_taxonomy_update_8001() {
/** @var \Drupal\user\Entity\Role[] $roles */
$roles = Role::loadMultiple();
/** @var \Drupal\taxonomy\Entity\Vocabulary[] $vocabularies */
$vocabularies = Vocabulary::loadMultiple();
foreach ($roles as $role) {
foreach ($vocabularies as $vocabulary) {
if ($role
->hasPermission('access content')) {
$role
->grantPermission('view published terms in ' . $vocabulary
->id());
}
if ($role
->hasPermission('view own unpublished content')) {
$role
->grantPermission('view unpublished terms in ' . $vocabulary
->id());
}
$role
->save();
}
}
}