You are here

url_alias_permissions.install in URL Alias Permissions 8

Contains install and update functions for URL Alias Permissions.

File

url_alias_permissions.install
View source
<?php

/**
 * @file
 * Contains install and update functions for URL Alias Permissions.
 */
use Drupal\node\Entity\NodeType;
use Drupal\user\Entity\Role;

/**
 * Convert URL alias permissions to the new ones.
 */
function url_alias_permissions_update_8001() {
  $roles = Role::loadMultiple();
  $node_types = NodeType::loadMultiple();
  foreach ($roles as $role) {
    foreach ($node_types as $node_type) {
      if ($role
        ->hasPermission("edit {$node_type->id()} URL alias")) {
        $role
          ->grantPermission("edit {$node_type->id()} node url alias");
        $role
          ->revokePermission("edit {$node_type->id()} URL alias");
      }
      $role
        ->save();
    }
  }
}

Functions

Namesort descending Description
url_alias_permissions_update_8001 Convert URL alias permissions to the new ones.