public function GroupRequestController::requestMembership in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::requestMembership()
- 10.3.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::requestMembership()
- 10.0.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::requestMembership()
- 10.1.x modules/social_features/social_group/modules/social_group_request/src/Controller/GroupRequestController.php \Drupal\social_group_request\Controller\GroupRequestController::requestMembership()
Callback to request membership.
File
- modules/
social_features/ social_group/ modules/ social_group_request/ src/ Controller/ GroupRequestController.php, line 123
Class
- GroupRequestController
- Returns responses for Group request routes.
Namespace
Drupal\social_group_request\ControllerCode
public function requestMembership(GroupInterface $group) {
$response = new AjaxResponse();
$contentTypeConfigId = $group
->getGroupType()
->getContentPlugin('group_membership_request')
->getContentTypeConfigId();
$request = $this
->entityTypeManager()
->getStorage('group_content')
->getQuery()
->condition('type', $contentTypeConfigId)
->condition('gid', $group
->id())
->condition('entity_id', $this
->currentUser()
->id())
->condition('grequest_status', GroupMembershipRequest::REQUEST_PENDING)
->count()
->execute();
if ($request == 0) {
$request_form = $this
->formBuilder()
->getForm(GroupRequestMembershipRequestForm::class, $group);
$response
->addCommand(new OpenModalDialogCommand($this
->t('Request to join'), $request_form, [
'width' => '582px',
'dialogClass' => 'social_group-popup',
]));
}
return $response;
}