diff --git a/og.services.yml b/og.services.yml index 45e31dacf..be1821d89 100644 --- a/og.services.yml +++ b/og.services.yml @@ -21,7 +21,7 @@ services: - { name: 'cache.context'} og.access: class: Drupal\og\OgAccess - arguments: ['@config.factory', '@current_user', '@module_handler', '@og.group_type_manager', '@og.permission_manager', '@og.membership_manager', '@og.group_audience_helper'] + arguments: ['@config.factory', '@current_user', '@module_handler', '@og.group_type_manager', '@og.permission_manager', '@og.membership_manager'] og.context: class: Drupal\og\ContextProvider\OgContext arguments: ['@plugin.manager.og.group_resolver', '@config.factory'] diff --git a/src/OgAccess.php b/src/OgAccess.php index 7317f30c7..7439e192f 100644 --- a/src/OgAccess.php +++ b/src/OgAccess.php @@ -76,13 +76,6 @@ class OgAccess implements OgAccessInterface { */ protected $membershipManager; - /** - * The OG group audience helper. - * - * @var \Drupal\og\OgGroupAudienceHelperInterface - */ - protected $groupAudienceHelper; - /** * Constructs the OgAccess service. * @@ -98,17 +91,14 @@ class OgAccess implements OgAccessInterface { * The permission manager. * @param \Drupal\og\MembershipManagerInterface $membership_manager * The group membership manager. - * @param \Drupal\og\OgGroupAudienceHelperInterface $group_audience_helper - * The OG group audience helper. */ - public function __construct(ConfigFactoryInterface $config_factory, AccountProxyInterface $account_proxy, ModuleHandlerInterface $module_handler, GroupTypeManagerInterface $group_manager, PermissionManagerInterface $permission_manager, MembershipManagerInterface $membership_manager, OgGroupAudienceHelperInterface $group_audience_helper) { + public function __construct(ConfigFactoryInterface $config_factory, AccountProxyInterface $account_proxy, ModuleHandlerInterface $module_handler, GroupTypeManagerInterface $group_manager, PermissionManagerInterface $permission_manager, MembershipManagerInterface $membership_manager) { $this->configFactory = $config_factory; $this->accountProxy = $account_proxy; $this->moduleHandler = $module_handler; $this->groupTypeManager = $group_manager; $this->permissionManager = $permission_manager; $this->membershipManager = $membership_manager; - $this->groupAudienceHelper = $group_audience_helper; } /** @@ -230,8 +220,7 @@ public function userAccessEntity($operation, EntityInterface $entity, AccountInt } } - $is_group_content = $this->groupAudienceHelper->hasGroupAudienceField($entity_type_id, $bundle); - if ($is_group_content) { + if ($this->groupTypeManager->isGroupContent($entity_type_id, $bundle)) { $cache_tags = $entity_type->getListCacheTags(); // The entity might be a user or a non-user entity. diff --git a/tests/src/Unit/OgAccessEntityTestBase.php b/tests/src/Unit/OgAccessEntityTestBase.php index 4baf2dd78..8087db9e3 100644 --- a/tests/src/Unit/OgAccessEntityTestBase.php +++ b/tests/src/Unit/OgAccessEntityTestBase.php @@ -50,9 +50,9 @@ protected function setUp(): void { $this->groupContentEntity->getEntityTypeId()->willReturn($entity_type_id); $this->addCache($this->groupContentEntity); - // If the group audience helper is asked if the group content entity has any - // group audience fields, it is expected that this will return TRUE. - $this->groupAudienceHelper->hasGroupAudienceField($entity_type_id, $bundle) + // If the group type manager is asked if the group content entity is group + // content, it is expected that this will return TRUE. + $this->groupTypeManager->isGroupContent($entity_type_id, $bundle) ->willReturn(TRUE); // It is expected that a list of entity operation permissions is retrieved diff --git a/tests/src/Unit/OgAccessTestBase.php b/tests/src/Unit/OgAccessTestBase.php index 6e1a25728..2652bae9f 100644 --- a/tests/src/Unit/OgAccessTestBase.php +++ b/tests/src/Unit/OgAccessTestBase.php @@ -98,13 +98,6 @@ class OgAccessTestBase extends UnitTestCase { */ protected $membershipManager; - /** - * The OG group audience helper. - * - * @var \Drupal\og\OgGroupAudienceHelperInterface - */ - protected $groupAudienceHelper; - /** * The entity type manager service. * @@ -178,8 +171,6 @@ protected function setUp(): void { $this->membershipManager->getGroupCount(Argument::any())->willReturn(1); $this->membership->getRoles()->willReturn([$this->ogRole->reveal()]); - $this->groupAudienceHelper = $this->prophesize(OgGroupAudienceHelperInterface::class); - // @todo: Move to test. $this->ogRole->isAdmin()->willReturn(FALSE); $this->ogRole->getPermissions()->willReturn(['update group']); @@ -196,8 +187,7 @@ protected function setUp(): void { $module_handler->reveal(), $this->groupTypeManager->reveal(), $this->permissionManager->reveal(), - $this->membershipManager->reveal(), - $this->groupAudienceHelper->reveal() + $this->membershipManager->reveal() ); $container = new ContainerBuilder(); @@ -207,7 +197,6 @@ protected function setUp(): void { $container->set('module_handler', $this->prophesize(ModuleHandlerInterface::class)->reveal()); $container->set('og.group_type_manager', $this->groupTypeManager->reveal()); $container->set('og.membership_manager', $this->membershipManager->reveal()); - $container->set('og.group_audience_helper', $this->groupAudienceHelper->reveal()); // This is for caching purposes only. $container->set('current_user', $this->user->reveal());