Skip to content
This repository was archived by the owner on Aug 18, 2024. It is now read-only.

Commit a808daa

Browse files
authored
Merge pull request #748 from claudiu-cristea/array_merge-permissions
ISSUE-742: Non-node permissions overrides one each other
2 parents 406a715 + 0d53e71 commit a808daa

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/EventSubscriber/OgEventSubscriber.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ protected function getDefaultEntityOperationPermissions(array $group_content_bun
280280

281281
foreach ($group_content_bundle_ids as $group_content_entity_type_id => $bundle_ids) {
282282
foreach ($bundle_ids as $bundle_id) {
283-
$permissions += $this->generateEntityOperationPermissionList($group_content_entity_type_id, $bundle_id);
283+
$permissions = array_merge($permissions, $this->generateEntityOperationPermissionList($group_content_entity_type_id, $bundle_id));
284284
}
285285
}
286286

tests/src/Kernel/PermissionEventTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class PermissionEventTest extends KernelTestBase {
2626
* {@inheritdoc}
2727
*/
2828
public static $modules = [
29+
'entity_test',
2930
'field',
3031
'node',
3132
'og',
@@ -61,6 +62,9 @@ protected function setUp(): void {
6162
'type' => 'test_group_content',
6263
'name' => 'Test Group Content',
6364
])->save();
65+
// Create two entity_test bundles to test a mixed entity type case.
66+
entity_test_create_bundle('a_bundle', 'A bundle');
67+
entity_test_create_bundle('other_bundle', 'Other bundle');
6468
}
6569

6670
/**
@@ -200,6 +204,37 @@ public function permissionEventDataProvider() {
200204
$group_content_operation_permission,
201205
],
202206
],
207+
// Test a combination of bundles coming from different entity types.
208+
[
209+
[
210+
'node' => ['test_group_content'],
211+
'entity_test' => ['a_bundle', 'other_bundle'],
212+
],
213+
array_merge($default_permissions, [
214+
// node:test_group_content.
215+
'create test_group_content content',
216+
'delete any test_group_content content',
217+
'delete own test_group_content content',
218+
'edit any test_group_content content',
219+
'edit own test_group_content content',
220+
// entity_test:a_bundle.
221+
'create a_bundle entity_test',
222+
'delete any a_bundle entity_test',
223+
'delete own a_bundle entity_test',
224+
'update any a_bundle entity_test',
225+
'update own a_bundle entity_test',
226+
// entity_test:other_bundle.
227+
'create other_bundle entity_test',
228+
'delete any other_bundle entity_test',
229+
'delete own other_bundle entity_test',
230+
'update any other_bundle entity_test',
231+
'update own other_bundle entity_test',
232+
]),
233+
[
234+
$group_level_permission,
235+
$group_content_operation_permission,
236+
],
237+
],
203238
];
204239
}
205240

0 commit comments

Comments
 (0)