class JoinService in Opigno Learning path 3.x
Same name and namespace in other branches
- 8 src/JoinService.php \Drupal\opigno_learning_path\JoinService
Class JoinService.
Hierarchy
- class \Drupal\opigno_learning_path\JoinService
Expanded class hierarchy of JoinService
1 string reference to 'JoinService'
1 service uses JoinService
File
- src/
JoinService.php, line 12
Namespace
Drupal\opigno_learning_pathView source
class JoinService {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $currentUser;
/**
* The entity form builder.
*
* @var \Drupal\Core\Entity\EntityFormBuilderInterface
*/
protected $entityFormBuilder;
/**
* Constructs a new JoinService object.
*/
public function __construct(AccountInterface $current_user, EntityFormBuilderInterface $entity_form_builder) {
$this->currentUser = $current_user;
$this->entityFormBuilder = $entity_form_builder;
}
/**
* {@inheritdoc}
*/
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');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JoinService:: |
protected | property | The current user. | |
JoinService:: |
protected | property | The entity form builder. | |
JoinService:: |
public | function | ||
JoinService:: |
public | function | Constructs a new JoinService object. |