Skip to content

Commit

Permalink
Merge pull request #121 from localgovdrupal/feature/113-geo-browser-p…
Browse files Browse the repository at this point in the history
…ermission-to-roles

Issue 113: Granting 'create geo' and 'access geo_entity_library entity browser pages'  permissions
  • Loading branch information
finnlewis committed Jun 18, 2024
2 parents 075f4f8 + af694dc commit 0b49821
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
24 changes: 24 additions & 0 deletions localgov_geo.install
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* Install, update and uninstall functions for the localgov_geo module.
*/

use Drupal\localgov_roles\RolesHelper;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;

/**
Expand Down Expand Up @@ -37,3 +39,25 @@ function localgov_geo_update_last_removed() {
// Removed all pre-Drupal 10 hooks that updated things now in geo_entity.
return 8810;
}

/**
* Expanding geo permissions.
*
* Granting 'create geo' and 'access geo_entity_library entity browser pages'
* permissions to Editor, Author and Contributor roles.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
function localgov_geo_update_10001() {
$roles = Role::loadMultiple([
RolesHelper::EDITOR_ROLE,
RolesHelper::AUTHOR_ROLE,
RolesHelper::CONTRIBUTOR_ROLE,
]);

foreach ($roles as $role) {
$role->grantPermission('create geo');
$role->grantPermission('access geo_entity_library entity browser pages');
$role->save();
}
}
5 changes: 5 additions & 0 deletions localgov_geo.module
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ function localgov_geo_localgov_roles_default() {
'create geo',
'access geo_entity_library entity browser pages',
],
// @codingStandardsIgnoreLine
\Drupal\localgov_roles\RolesHelper::CONTRIBUTOR_ROLE => [
'create geo',
'access geo_entity_library entity browser pages',
],
];
}

Expand Down

0 comments on commit 0b49821

Please sign in to comment.