public static function Og::createMembership in Organic groups 8
Creates an OG membership.
Parameters
\Drupal\Core\Entity\EntityInterface $group: The group entity.
\Drupal\Core\Session\AccountInterface $user: The user object.
string $membership_type: (optional) The membership type. Defaults to \Drupal\og\OgMembershipInterface::TYPE_DEFAULT.
Return value
\Drupal\og\Entity\OgMembership The unsaved membership object.
13 calls to Og::createMembership()
- GroupLevelAccessTest::createUserWithOgRole in tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php - Creates a test user and assigns it a membership with the given role.
- GroupLevelAccessTest::setupUserAccessArbitraryPermissions in tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php - Sets up a matrix of users and roles with arbitrary permissions.
- GroupLevelAccessTest::testUserAccessArbitraryPermissions in tests/
src/ Kernel/ Access/ GroupLevelAccessTest.php - Test access to an arbitrary permission.
- OgMembershipTest::testGetSetState in tests/
src/ Kernel/ Entity/ OgMembershipTest.php - Tests boolean check for states.
- OgMembershipTest::testIsOwner in tests/
src/ Kernel/ Entity/ OgMembershipTest.php - Tests that the membership can return if it belongs to the group owner.
File
- src/
Og.php, line 187
Class
- Og
- A static helper class for OG.
Namespace
Drupal\ogCode
public static function createMembership(EntityInterface $group, AccountInterface $user, $membership_type = OgMembershipInterface::TYPE_DEFAULT) {
/** @var \Drupal\og\MembershipManagerInterface $membership_manager */
$membership_manager = \Drupal::service('og.membership_manager');
return $membership_manager
->createMembership($group, $user, $membership_type);
}