You are here

public function GroupMembershipController::join in Group 8

Same name and namespace in other branches
  1. 2.0.x src/Controller/GroupMembershipController.php \Drupal\group\Controller\GroupMembershipController::join()

Provides the form for joining a group.

Parameters

\Drupal\group\Entity\GroupInterface $group: The group to join.

Return value

array A group join form.

1 string reference to 'GroupMembershipController::join'
group.routing.yml in ./group.routing.yml
group.routing.yml

File

src/Controller/GroupMembershipController.php, line 66

Class

GroupMembershipController
Provides group membership route controllers.

Namespace

Drupal\group\Controller

Code

public function join(GroupInterface $group) {

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

  // Pre-populate a group membership with the current user.
  $group_content = GroupContent::create([
    'type' => $plugin
      ->getContentTypeConfigId(),
    'gid' => $group
      ->id(),
    'entity_id' => $this->currentUser
      ->id(),
  ]);
  return $this->entityFormBuilder
    ->getForm($group_content, 'group-join');
}