public function ILT::isMember in Opigno Instructor-led Trainings 8
Same name and namespace in other branches
- 3.x src/Entity/ILT.php \Drupal\opigno_ilt\Entity\ILT::isMember()
Checks if the user is a member of the ILT or related training.
Parameters
int $user_id: User ID.
Return value
bool TRUE if the user is a member, FALSE otherwise.
Overrides ILTInterface::isMember
File
- src/
Entity/ ILT.php, line 340
Class
- ILT
- Defines the ILT entity.
Namespace
Drupal\opigno_ilt\EntityCode
public function isMember($user_id) {
$members_ids = $this
->getMembersIds();
if (empty($members_ids)) {
$training = $this
->getTraining();
if (isset($training)) {
$members_ids = array_map(function ($member) {
/** @var \Drupal\group\GroupMembership $member */
return $member
->getUser()
->id();
}, $training
->getMembers());
}
}
if (!in_array($user_id, $members_ids)) {
return FALSE;
}
return TRUE;
}