From 759407d8b461a8635414b0dab664e0c01fb26ed0 Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Tue, 28 Nov 2023 12:43:16 +1100 Subject: [PATCH 1/4] grant permission to approver to create/update terms in sites --- tide_site.install | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tide_site.install b/tide_site.install index 8334805..769a224 100644 --- a/tide_site.install +++ b/tide_site.install @@ -5,6 +5,8 @@ * Install file for tide_site. */ + use Drupal\user\Entity\Role; + /** * Implements hook_install(). */ @@ -17,3 +19,14 @@ function tide_site_install() { } } } + +/** + * Approver should have permission to create/edit terms in sites. + */ +function tide_site_update_10000() { + $approver = Role::load('approver'); + if ($approver) { + $approver->grantPermission('create terms in sites', 'edit terms in sites'); + $approver->save(); + } +} From 0fffc9df27f8c43473dfbb8e7a1e90982c89e9f0 Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Tue, 28 Nov 2023 12:52:22 +1100 Subject: [PATCH 2/4] fixed lint --- tide_site.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tide_site.install b/tide_site.install index 769a224..6a0697c 100644 --- a/tide_site.install +++ b/tide_site.install @@ -5,7 +5,7 @@ * Install file for tide_site. */ - use Drupal\user\Entity\Role; +use Drupal\user\Entity\Role; /** * Implements hook_install(). From 039025e6d285385433b948de092e10ed85f24d19 Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Wed, 29 Nov 2023 18:03:55 +1100 Subject: [PATCH 3/4] added array permissions --- tide_site.install | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tide_site.install b/tide_site.install index 6a0697c..6978590 100644 --- a/tide_site.install +++ b/tide_site.install @@ -25,8 +25,14 @@ function tide_site_install() { */ function tide_site_update_10000() { $approver = Role::load('approver'); + $permissions = [ + 'create terms in sites', + 'edit terms in sites', + ]; if ($approver) { - $approver->grantPermission('create terms in sites', 'edit terms in sites'); + foreach ($permissions as $permission) { + $approver->grantPermission($permission); + } $approver->save(); } } From 710b12f6ac281ec1bb7e23f8f482e2da9df14797 Mon Sep 17 00:00:00 2001 From: Yeni Atencio Date: Wed, 29 Nov 2023 18:13:48 +1100 Subject: [PATCH 4/4] fixed lint --- tide_site.install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tide_site.install b/tide_site.install index 6978590..8d6b78c 100644 --- a/tide_site.install +++ b/tide_site.install @@ -28,7 +28,7 @@ function tide_site_update_10000() { $permissions = [ 'create terms in sites', 'edit terms in sites', - ]; + ]; if ($approver) { foreach ($permissions as $permission) { $approver->grantPermission($permission);