You are here

public function GroupRequestController::approveRequest in Open Social 10.2.x

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::approveRequest()
  2. 10.3.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::approveRequest()
  3. 10.0.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::approveRequest()
  4. 10.1.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::approveRequest()

Builds the form to create new membership on membership request approve.

File

modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php, line 104

Class

GroupRequestController
Returns responses for Group request routes.

Namespace

Drupal\social_group_request\Controller

Code

public function approveRequest(GroupInterface $group, GroupContentInterface $group_content) {

  /** @var \Drupal\group\Plugin\GroupContentEnablerInterface $plugin */
  $plugin = $group
    ->getGroupType()
    ->getContentPlugin('group_membership');

  // Pre-populate a group membership from Membership request.
  $group_content = $this
    ->entityTypeManager()
    ->getStorage('group_content')
    ->create([
    'type' => $plugin
      ->getContentTypeConfigId(),
    'gid' => $group
      ->id(),
    'entity_id' => $group_content
      ->getEntity()
      ->id(),
  ]);
  $this->cacheTagsInvalidator
    ->invalidateTags([
    'request-membership:' . $group
      ->id(),
  ]);
  return $this
    ->entityFormBuilder()
    ->getForm($group_content, 'add');
}