public function GroupMembership::__construct in Group 8
Same name and namespace in other branches
- 2.0.x src/GroupMembership.php \Drupal\group\GroupMembership::__construct()
Constructs a new GroupMembership.
Parameters
\Drupal\group\Entity\GroupContentInterface $group_content: The group content entity representing the membership.
Throws
\Exception Exception thrown when trying to instantiate this class with a GroupContent entity that was not based on the GroupMembership content enabler plugin.
File
- src/
GroupMembership.php, line 33
Class
- GroupMembership
- Wrapper class for a GroupContent entity representing a membership.
Namespace
Drupal\groupCode
public function __construct(GroupContentInterface $group_content) {
if ($group_content
->getGroupContentType()
->getContentPluginId() == 'group_membership') {
$this->groupContent = $group_content;
}
else {
throw new \Exception('Trying to create a GroupMembership from an incompatible GroupContent entity.');
}
}