diff --git a/composer.json b/composer.json index 44a17521b68a6f7dabddd74bab2fb602c61a2a46..39438dea80188a83c42de5297d668093b43b9a84 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "license": "GPL-2.0-or-later", "minimum-stability": "dev", "require": { - "drupal/core": "^9.5 || ^10", + "drupal/core": "^10.3 || ^11", "drupal/group": "^3.0" }, "require-dev": { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 592be9c07e456a8f08f347ef3f4d4d373a258985..58d3f9b2697a38a333645d293f9d23639fd2dc83 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1,26 +1,6 @@ parameters: ignoreErrors: - - - message: "#^Call to an undefined method Drupal\\\\group\\\\Plugin\\\\Group\\\\RelationHandler\\\\RelationHandlerInterface\\:\\:getGroupOperations\\(\\)\\.$#" - count: 1 - path: src/Plugin/Group/RelationHandler/SubgroupOperationProvider.php - - - - message: "#^Call to an undefined method Drupal\\\\group\\\\Plugin\\\\Group\\\\RelationHandler\\\\RelationHandlerInterface\\:\\:getOperations\\(\\)\\.$#" - count: 1 - path: src/Plugin/Group/RelationHandler/SubgroupOperationProvider.php - - - - message: "#^Call to an undefined method Drupal\\\\group\\\\Plugin\\\\Group\\\\RelationHandler\\\\RelationHandlerInterface\\:\\:getPermission\\(\\)\\.$#" - count: 1 - path: src/Plugin/Group/RelationHandler/SubgroupPermissionProvider.php - - message: "#^Cannot access property \\$data on false\\.$#" count: 1 path: tests/src/Kernel/RoleInheritanceTest.php - - - - message: "#^Cannot access property \\$data on object\\|false\\.$#" - count: 5 - path: tests/src/Kernel/RoleInheritanceTest.php diff --git a/src/Access/InheritedGroupPermissionCalculator.php b/src/Access/InheritedGroupPermissionCalculator.php index 7f9663925beee7f82412c5707dddb26d07bc2914..91260fe7598765dbef0883cdd92f6806079dc540 100644 --- a/src/Access/InheritedGroupPermissionCalculator.php +++ b/src/Access/InheritedGroupPermissionCalculator.php @@ -3,6 +3,7 @@ namespace Drupal\subgroup\Access; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem; use Drupal\Core\Session\AccountInterface; use Drupal\flexible_permissions\CalculatedPermissionsItem; use Drupal\flexible_permissions\PermissionCalculatorBase; @@ -126,7 +127,8 @@ class InheritedGroupPermissionCalculator extends PermissionCalculatorBase { } // Add the individual roles assigned to the member to the list. - foreach ($group_membership->getGroupRelationship()->group_roles as $group_role_ref) { + foreach ($group_membership->getGroupRelationship()->get('group_roles') as $group_role_ref) { + assert($group_role_ref instanceof EntityReferenceItem); $role_ids[] = $group_role_ref->target_id; } diff --git a/src/EventSubscriber/GroupTypeLeafSubscriber.php b/src/EventSubscriber/GroupTypeLeafSubscriber.php index 549cb428e5d958df71fc09865e93942eedcff9db..6c27ab7653d92290092220f02a3d1c0cb8dbfba1 100644 --- a/src/EventSubscriber/GroupTypeLeafSubscriber.php +++ b/src/EventSubscriber/GroupTypeLeafSubscriber.php @@ -62,7 +62,7 @@ class GroupTypeLeafSubscriber implements EventSubscriberInterface { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { $events[LeafEvents::GROUP_TYPE_LEAF_ADD] = 'onAddLeaf'; $events[LeafEvents::GROUP_TYPE_LEAF_IMPORT] = 'onImportLeaf'; $events[LeafEvents::GROUP_TYPE_LEAF_REMOVE] = 'onRemoveLeaf'; diff --git a/src/EventSubscriber/TreeCacheTagInvalidator.php b/src/EventSubscriber/TreeCacheTagInvalidator.php index 0102a1c60b0f32436ddde335990b2388a619ab1a..f565fdf12e3a116251919abcf217f21fe4be9758 100644 --- a/src/EventSubscriber/TreeCacheTagInvalidator.php +++ b/src/EventSubscriber/TreeCacheTagInvalidator.php @@ -52,7 +52,7 @@ class TreeCacheTagInvalidator implements EventSubscriberInterface { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { $events[LeafEvents::GROUP_LEAF_ADD] = 'onAddGroupLeaf'; $events[LeafEvents::GROUP_LEAF_REMOVE] = 'onRemoveGroupLeaf'; $events[LeafEvents::GROUP_TYPE_LEAF_ADD] = 'onAddGroupTypeLeaf'; diff --git a/subgroup.info.yml b/subgroup.info.yml index 382c517e5125b8c53eef0a9dd86399571793af1a..e352078074d32b2af32ffdb424abf1f0f7d38bb7 100644 --- a/subgroup.info.yml +++ b/subgroup.info.yml @@ -2,7 +2,7 @@ name: 'Subgroup' description: 'Allows you to structure groups into a hierarchical tree with permissions inheriting up or down' package: 'Group' type: 'module' -core_version_requirement: ^9.5 || ^10 +core_version_requirement: ^10.3 || ^11 configure: 'subgroup.settings' dependencies: - 'group:group' diff --git a/subgroup.module b/subgroup.module index 8fdc787fb85cdf9fe8f7fc50488731ce69711c3a..125d47e39e743799159410dedb00add55c69c617 100644 --- a/subgroup.module +++ b/subgroup.module @@ -87,7 +87,7 @@ function subgroup_group_update(GroupInterface $group) { // Find out whether the group was added to or removed from a tree and dispatch // the appropriate event. if ($current_is_leaf !== $original_is_leaf) { - /** @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher */ + /** @var \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher */ $event_dispatcher = \Drupal::service('event_dispatcher'); $event = new GroupLeafEvent($group); if ($current_is_leaf) { @@ -110,7 +110,7 @@ function subgroup_group_type_insert(GroupTypeInterface $group_type) { // Subgroup metadata, we need to fire the import event so we can, for example, // clear the plugin definitions cache. if ($subgroup_handler->isLeaf($group_type) && $group_type->isSyncing()) { - /** @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher */ + /** @var \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher */ $event_dispatcher = \Drupal::service('event_dispatcher'); $event = new GroupTypeLeafEvent($group_type); $event_dispatcher->dispatch($event, LeafEvents::GROUP_TYPE_LEAF_IMPORT); @@ -132,7 +132,7 @@ function subgroup_group_type_update(GroupTypeInterface $group_type) { // Find out whether the group type was added to or removed from a tree and // dispatch the appropriate event. if ($current_is_leaf !== $original_is_leaf) { - /** @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher */ + /** @var \Symfony\Component\EventDispatcher\EventDispatcher $event_dispatcher */ $event_dispatcher = \Drupal::service('event_dispatcher'); $event = new GroupTypeLeafEvent($group_type); if ($group_type->isSyncing()) { diff --git a/tests/modules/subgroup_test_events/src/EventSubscriber/LeafEventsSubscriber.php b/tests/modules/subgroup_test_events/src/EventSubscriber/LeafEventsSubscriber.php index 7ea3e0b93f0f969f1069aed0b82d5ec0dc4f23b4..47e183f1370dd04915bbbeadaf77b3a4fea4e46c 100644 --- a/tests/modules/subgroup_test_events/src/EventSubscriber/LeafEventsSubscriber.php +++ b/tests/modules/subgroup_test_events/src/EventSubscriber/LeafEventsSubscriber.php @@ -15,7 +15,7 @@ class LeafEventsSubscriber implements EventSubscriberInterface { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { $events[LeafEvents::GROUP_LEAF_ADD] = 'onAddGroupLeaf'; $events[LeafEvents::GROUP_LEAF_REMOVE] = 'onRemoveGroupLeaf'; $events[LeafEvents::GROUP_TYPE_LEAF_ADD] = 'onAddGroupTypeLeaf'; diff --git a/tests/src/Kernel/GroupCreateTest.php b/tests/src/Kernel/GroupCreateTest.php index 1e86a6cb60fd80abb0aa166e2ce17b73879da876..e45fb15f374faf5532e7dd691aa7df2e68e6202a 100644 --- a/tests/src/Kernel/GroupCreateTest.php +++ b/tests/src/Kernel/GroupCreateTest.php @@ -31,7 +31,7 @@ class GroupCreateTest extends SubgroupKernelTestBase { $bar = $this->createGroupType(['id' => 'bar']); // Grant create access for the current user. - $this->setCurrentUser($this->createUser([], ['create foo group', 'create bar group'])); + $this->setCurrentUser($this->createUser(['create foo group', 'create bar group'])); /** @var \Drupal\subgroup\Entity\GroupTypeSubgroupHandler $group_type_handler */ $group_type_handler = $this->entityTypeManager->getHandler('group_type', 'subgroup'); @@ -44,7 +44,7 @@ class GroupCreateTest extends SubgroupKernelTestBase { */ public function testRegularCreateAccess() { $this->createGroupType(['id' => 'baz']); - $this->setCurrentUser($this->createUser([], ['create baz group'])); + $this->setCurrentUser($this->createUser(['create baz group'])); $this->assertTrue($this->accessControlHandler->createAccess('baz'), 'Group can be created just fine.'); } diff --git a/tests/src/Kernel/GroupTypeDeleteTest.php b/tests/src/Kernel/GroupTypeDeleteTest.php index d458bba10abe4a43a17d19115ab9c0f4f42550b7..cae720d816cedea8657f9ab0abc54c47b65a7697 100644 --- a/tests/src/Kernel/GroupTypeDeleteTest.php +++ b/tests/src/Kernel/GroupTypeDeleteTest.php @@ -28,7 +28,7 @@ class GroupTypeDeleteTest extends SubgroupKernelTestBase { $this->subgroupHandler = $this->entityTypeManager->getHandler('group_type', 'subgroup'); // Grant delete access for the current user. - $this->setCurrentUser($this->createUser([], ['administer group'])); + $this->setCurrentUser($this->createUser(['administer group'])); } /** diff --git a/tests/src/Kernel/InheritedGroupPermissionCalculatorTest.php b/tests/src/Kernel/InheritedGroupPermissionCalculatorTest.php index edacc3ef938b017271d1426193a545676c7af9ce..d6858fe55d13224a680a2e02c3ffe35960435cb3 100644 --- a/tests/src/Kernel/InheritedGroupPermissionCalculatorTest.php +++ b/tests/src/Kernel/InheritedGroupPermissionCalculatorTest.php @@ -300,9 +300,8 @@ class InheritedGroupPermissionCalculatorTest extends SubgroupKernelTestBase { $this->assertTrue($group_gt1->hasPermission('view group', $this->account), 'Regular permissions still apply.'); $this->assertFalse($group_gt2->hasPermission('view group', $this->account), 'Regular permissions still apply.'); - $membership = $group_gt1->getMember($this->account)->getGroupRelationship(); - $membership->group_roles[] = 'gt1-viewer'; - $membership->save(); + $membership = $group_gt1->getMember($this->account); + $membership->addRole('gt1-viewer'); $this->assertTrue($group_gt1->hasPermission('view group', $this->account), 'Regular permissions still apply.'); $this->assertTrue($group_gt2->hasPermission('view group', $this->account), 'Account inherited member role from parent group.'); diff --git a/tests/src/Kernel/RoleInheritanceAccessControlHandlerTest.php b/tests/src/Kernel/RoleInheritanceAccessControlHandlerTest.php index 8a7d565a843a4237874af710dd7e65c2730a347a..3612c76271063c9e2e27fce49cdfc07ae92b8fd0 100644 --- a/tests/src/Kernel/RoleInheritanceAccessControlHandlerTest.php +++ b/tests/src/Kernel/RoleInheritanceAccessControlHandlerTest.php @@ -65,7 +65,7 @@ class RoleInheritanceAccessControlHandlerTest extends SubgroupKernelTestBase { public function testCreateAccess() { $access = $this->accessControlHandler->createAccess(NULL, NULL, [], TRUE); $this->assertFalse($access->isAllowed()); - $this->setCurrentUser($this->createUser([], ['administer subgroup'])); + $this->setCurrentUser($this->createUser(['administer subgroup'])); $access = $this->accessControlHandler->createAccess(NULL, NULL, [], TRUE); $this->assertTrue($access->isAllowed()); } @@ -81,7 +81,7 @@ class RoleInheritanceAccessControlHandlerTest extends SubgroupKernelTestBase { $this->assertInstanceOf(AccessResultForbidden::class, $access, 'Group create access check returned an AccessResultForbidden.'); $this->assertEquals('Role inheritance entities may not be updated after creation.', $access->getReason()); - $this->setCurrentUser($this->createUser([], ['administer subgroup'])); + $this->setCurrentUser($this->createUser(['administer subgroup'])); $access = $this->accessControlHandler->access($this->roleInheritance, 'update', NULL, TRUE); $this->assertInstanceOf(AccessResultForbidden::class, $access, 'Group create access check returned an AccessResultForbidden.'); $this->assertEquals('Role inheritance entities may not be updated after creation.', $access->getReason()); @@ -96,7 +96,7 @@ class RoleInheritanceAccessControlHandlerTest extends SubgroupKernelTestBase { $access = $this->accessControlHandler->access($this->roleInheritance, 'delete', NULL, TRUE); $this->assertFalse($access->isAllowed()); - $this->setCurrentUser($this->createUser([], ['administer subgroup'])); + $this->setCurrentUser($this->createUser(['administer subgroup'])); $access = $this->accessControlHandler->access($this->roleInheritance, 'delete', NULL, TRUE); $this->assertTrue($access->isAllowed()); } diff --git a/tests/src/Kernel/SubgroupKernelTestBase.php b/tests/src/Kernel/SubgroupKernelTestBase.php index bd9c4060d09a6a76377c2a9bd9590b8b58208a10..8885e8f0509c83dba4d81eaf294ecbb5db53c295 100644 --- a/tests/src/Kernel/SubgroupKernelTestBase.php +++ b/tests/src/Kernel/SubgroupKernelTestBase.php @@ -20,7 +20,6 @@ abstract class SubgroupKernelTestBase extends EntityKernelTestBase { 'group', 'options', 'subgroup', - 'variationcache', ]; /** diff --git a/tests/src/Unit/SubgroupHandlerBaseTest.php b/tests/src/Unit/SubgroupHandlerBaseTest.php index 706e726c0983af1207400f628e1e515051f5a32e..cba3afaebda3159624bc8f50a1b1964c8b2de8f4 100644 --- a/tests/src/Unit/SubgroupHandlerBaseTest.php +++ b/tests/src/Unit/SubgroupHandlerBaseTest.php @@ -61,7 +61,7 @@ class SubgroupHandlerBaseTest extends UnitTestCase { $storage = $this->prophesize(EntityStorageInterface::class); - $this->subgroupHandler = new TestSubgroubHandler($this->entityType->reveal(), $storage->reveal()); + $this->subgroupHandler = new TestSubgroupHandler($this->entityType->reveal(), $storage->reveal()); $this->subgroupHandler->setStringTranslation($this->getStringTranslationStub()); } @@ -328,7 +328,7 @@ class SubgroupHandlerBaseTest extends UnitTestCase { } // phpcs:disable -class TestSubgroubHandler extends SubgroupHandlerBase { +class TestSubgroupHandler extends SubgroupHandlerBase { /** * {@inheritdoc}