Skip to content

Commit

Permalink
Issue #3403634 by SV: Remove getMemberRole social_group module
Browse files Browse the repository at this point in the history
  • Loading branch information
volodymyr-sydor committed Jan 31, 2024
1 parent 5115dbc commit c5f4b46
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
5 changes: 3 additions & 2 deletions modules/social_features/social_group/social_group.module
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ function social_group_form_alter(&$form, FormStateInterface $form_state, $form_i
$gc_manager = \Drupal::service('group_relation_type.manager');

if (!$gc_manager->getRelationshipTypeIds('group_node:' . $entity->bundle())) {
unset($form['groups']);
unset($form['groups']);
}
}
}
Expand Down Expand Up @@ -2653,7 +2653,8 @@ function social_group_can_view_groups_of_type(string $type, AccountInterface $ac

// If members can see it, we also need to show group types because
// we are not calculation memberships.
$member = $group_type->getMemberRole();
$id = $group_type->id() . '-member';
$member = \Drupal::entityTypeManager()->getStorage('group_role')->load($id);
if (NULL !== $member && $member->hasPermission('view group')) {
return TRUE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
class ChangeGroupMembershipRole extends ViewsBulkOperationsActionBase implements ContainerFactoryPluginInterface, PluginFormInterface {

/**
* The group storage.
* The entity type manager service.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $storage;
protected EntityTypeManagerInterface $entityTypeManager;

/**
* The currently active route match object.
Expand Down Expand Up @@ -62,7 +62,7 @@ public function __construct(
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);

$this->storage = $entity_type_manager->getStorage('group');
$this->entityTypeManager = $entityTypeManager;
$this->routeMatch = $route_match;
}

Expand Down Expand Up @@ -168,11 +168,16 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
$id = $this->routeMatch->getRawParameter('group');

/** @var \Drupal\group\Entity\GroupTypeInterface $group_type */
$group_type = $this->storage->load($id)->getGroupType();
$group_type = $this->entityTypeManager
->getStorage('group')
->load($id)->getGroupType();

$roles = $group_type->getRoles(FALSE);
$id = $group_type->getMemberRoleId();
$roles[$id] = $group_type->getMemberRole();

// In case that getMemberRoleId() and getMemberRole() have been removed
// try to load directly.
$id = $group_type->id() . '-member';
$roles[$id] = $this->entityTypeManager->getStorage('group_role')->load($id);

$markup = $this->formatPlural($this->context['selected_count'],
'Choose which group roles to assign to the member you selected',
Expand Down

0 comments on commit c5f4b46

Please sign in to comment.