You are here

public function JoinService::getForm in Opigno Learning path 8

Same name and namespace in other branches
  1. 3.x src/JoinService.php \Drupal\opigno_learning_path\JoinService::getForm()

File

src/JoinService.php, line 39

Class

JoinService
Class JoinService.

Namespace

Drupal\opigno_learning_path

Code

public function getForm($group) {
  $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');
}