class OgMembership in Organic groups 8
The membership entity that connects a group and a user.
When dealing with non-user entities that are group content, that is content that is associated with a group, we do it via an entity reference field that has the default storage. The only information that we hold is that a group content is referencing a group.
However, when dealing with the user entity we recognize that we need to special case it. It won't suffice to just hold the reference between the user and the group content as it will be laking crucial information such as: the state of the user's membership in the group (active, pending or blocked), the time the membership was created, the user's OG role in the group, etc.
For this meta data we have the fieldable OgMembership entity, that is always connecting between a user and a group. There cannot be an OgMembership entity connecting two non-user entities.
Creating such a relation is done for example in the following way:
$membership = Og::createMembership($entity, $user);
$membership
->save();
Notice how the relation of the user to the group also includes the OG audience field name this association was done by. Like this we are able to express different membership types such as the default membership that comes out of the box, or a "premium membership" that can be for example expired after a certain amount of time (the logic for the expired membership in the example is out of the scope of OG core).
Having this field separation is what allows having multiple OG audience fields attached to the user, where each group they are associated with may be a result of different membership types.
Plugin annotation
@ContentEntityType(
id = "og_membership",
label = @Translation("OG membership"),
bundle_label = @Translation("OG membership type"),
module = "og",
base_table = "og_membership",
fieldable = TRUE,
bundle_entity_type = "og_membership_type",
entity_keys = {
"uuid" = "uuid",
"id" = "id",
"bundle" = "type",
},
bundle_keys = {
"bundle" = "type",
},
handlers = {
"views_data" = "Drupal\og\OgMembershipViewsData",
"form" = {
"subscribe" = "Drupal\og\Form\GroupSubscribeForm",
"unsubscribe" = "Drupal\og\Form\GroupUnsubscribeConfirmForm",
},
}
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
- class \Drupal\og\Entity\OgMembership implements OgMembershipInterface
- class \Drupal\Core\Entity\ContentEntityBase implements \Drupal\Core\Entity\IteratorAggregate, ContentEntityInterface, TranslationStatusInterface uses EntityChangesDetectionTrait, SynchronizableEntityTrait
Expanded class hierarchy of OgMembership
12 files declare their use of OgMembership
- AccessByOgMembershipTest.php in tests/
src/ Kernel/ Access/ AccessByOgMembershipTest.php - AddSingleOgMembershipRole.php in src/
Plugin/ Action/ AddSingleOgMembershipRole.php - ChangeOgMembershipStateBase.php in src/
Plugin/ Action/ ChangeOgMembershipStateBase.php - DeleteOgMembership.php in src/
Plugin/ Action/ DeleteOgMembership.php - GroupSubscribeFormTest.php in tests/
src/ Kernel/ Form/ GroupSubscribeFormTest.php
File
- src/
Entity/ OgMembership.php, line 83
Namespace
Drupal\og\EntityView source
class OgMembership extends ContentEntityBase implements OgMembershipInterface {
/**
* {@inheritdoc}
*/
public function getCreatedTime() : int {
return $this
->getFieldValue('created', 'value') ?: 0;
}
/**
* {@inheritdoc}
*/
public function setCreatedTime(int $timestamp) : OgMembershipInterface {
$this
->set('created', $timestamp);
return $this;
}
/**
* {@inheritdoc}
*/
public function getOwner() {
assert(!empty($this
->get('uid')->entity), new \LogicException(__METHOD__ . '() should only be called on loaded memberships, or on newly created memberships that already have the owner set.'));
return $this
->get('uid')->entity;
}
/**
* {@inheritdoc}
*/
public function getOwnerId() {
$owner_id = $this
->getFieldValue('uid', 'target_id');
assert(!empty($owner_id), new \LogicException(__METHOD__ . '() should only be called on loaded memberships, or on newly created memberships that already have the owner set.'));
return $owner_id;
}
/**
* {@inheritdoc}
*/
public function setOwner(UserInterface $account) {
$this
->set('uid', $account
->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function setOwnerId($uid) {
$this
->set('uid', $uid);
return $this;
}
/**
* {@inheritdoc}
*/
public function setGroup(ContentEntityInterface $group) : OgMembershipInterface {
$this
->set('entity_type', $group
->getEntityTypeId());
$this
->set('entity_bundle', $group
->bundle());
$this
->set('entity_id', $group
->id());
return $this;
}
/**
* {@inheritdoc}
*/
public function getGroupEntityType() : string {
$entity_type = $this
->getFieldValue('entity_type', 'value') ?: '';
assert(!empty($entity_type), new \LogicException(__METHOD__ . '() should only be called on loaded memberships, or on newly created memberships that already have the group type set.'));
return $entity_type;
}
/**
* {@inheritdoc}
*/
public function getGroupBundle() : string {
$bundle = $this
->getFieldValue('entity_bundle', 'value') ?: '';
assert(!empty($bundle), new \LogicException(__METHOD__ . '() should only be called on loaded memberships, or on newly created memberships that already have the group bundle set.'));
return $bundle;
}
/**
* {@inheritdoc}
*/
public function getGroupId() : string {
$entity_id = $this
->getFieldValue('entity_id', 'value') ?: '';
assert(!empty($entity_id), new \LogicException(__METHOD__ . '() should only be called on loaded memberships, or on newly created memberships that already have the group ID set.'));
return $entity_id;
}
/**
* Checks if a group has already been populated on the membership.
*
* The group is required for a membership, so it is always present if a
* membership has been saved. This is intended for internal use to verify if
* a group is present when methods are called on a membership that is possibly
* still under construction.
*
* For performance reasons this avoids loading the full group entity just for
* this purpose, and relies only on the fact that the data for the entity is
* populated in the relevant fields. This should give us the same indication,
* but with a lower performance cost, especially for users that are a member
* of a large number of groups.
*
* @return bool
* Whether or not the group is already present.
*/
protected function hasGroup() : bool {
$has_group = !empty($this
->getFieldValue('entity_type', 'value')) && !empty($this
->getFieldValue('entity_bundle', 'value')) && !empty($this
->getFieldValue('entity_id', 'value'));
return $has_group;
}
/**
* {@inheritdoc}
*/
public function getGroup() : ?ContentEntityInterface {
$entity_type = $this
->getGroupEntityType();
$entity_id = $this
->getGroupId();
return \Drupal::entityTypeManager()
->getStorage($entity_type)
->load($entity_id);
}
/**
* {@inheritdoc}
*/
public function setState(string $state) : OgMembershipInterface {
$this
->set('state', $state);
return $this;
}
/**
* {@inheritdoc}
*/
public function getState() : string {
return $this
->getFieldValue('state', 'value') ?: '';
}
/**
* {@inheritdoc}
*/
public function getType() : string {
return $this
->bundle();
}
/**
* {@inheritdoc}
*/
public function addRole(OgRoleInterface $role) : OgMembershipInterface {
$roles = $this
->getRoles();
$roles[] = $role;
return $this
->setRoles($roles);
}
/**
* {@inheritdoc}
*/
public function revokeRole(OgRoleInterface $role) : OgMembershipInterface {
return $this
->revokeRoleById($role
->id());
}
/**
* {@inheritdoc}
*/
public function revokeRoleById(string $role_id) : OgMembershipInterface {
$roles = $this
->getRoles();
foreach ($roles as $key => $existing_role) {
if ($existing_role
->id() == $role_id) {
unset($roles[$key]);
// We can stop iterating.
break;
}
}
return $this
->setRoles($roles);
}
/**
* {@inheritdoc}
*/
public function getRoles() : array {
$roles = [];
// Add the member role. This is only possible if a group has been set on the
// membership.
if ($this
->hasGroup()) {
$roles = [
OgRole::getRole($this
->getGroupEntityType(), $this
->getGroupBundle(), OgRoleInterface::AUTHENTICATED),
];
}
$roles = array_merge($roles, $this
->get('roles')
->referencedEntities());
return $roles;
}
/**
* {@inheritdoc}
*/
public function setRoles(array $roles = []) : OgMembershipInterface {
$roles = array_filter($roles, function (OgRole $role) {
return !($role
->getName() == OgRoleInterface::AUTHENTICATED);
});
$role_ids = array_map(function (OgRole $role) {
return $role
->id();
}, $roles);
$this
->set('roles', array_unique($role_ids));
return $this;
}
/**
* {@inheritdoc}
*/
public function getRolesIds() : array {
// Only use $this->get() if it is already populated. If it is not available
// then use the raw value. This field is not translatable so we do not need
// the slow field definition lookup from $this->getTranslatedField().
if (isset($this->fields['roles'][LanguageInterface::LANGCODE_DEFAULT])) {
$values = $this
->get('roles')
->getValue();
}
else {
$values = $this->values['roles'][LanguageInterface::LANGCODE_DEFAULT] ?? [];
}
$roles_ids = array_column($values, 'target_id');
// Add the member role. This is only possible if a group has been set on the
// membership.
if ($this
->hasGroup()) {
$roles_ids[] = "{$this->getGroupEntityType()}-{$this->getGroupBundle()}-" . OgRoleInterface::AUTHENTICATED;
}
return $roles_ids;
}
/**
* {@inheritdoc}
*/
public function isRoleValid(OgRoleInterface $role) : bool {
$group = $this
->getGroup();
// If there is no group yet then we cannot determine whether the role is
// valid.
if (!$group) {
throw new \LogicException('Cannot determine whether a role is valid for a membership that doesn\'t have a group.');
}
// Non-member roles are never valid for any membership.
if ($role
->getName() == OgRoleInterface::ANONYMOUS) {
return FALSE;
}
elseif ($role
->getGroupType() !== $group
->getEntityTypeId() || $role
->getGroupBundle() !== $group
->bundle()) {
return FALSE;
}
return TRUE;
}
/**
* {@inheritdoc}
*/
public function hasRole(string $role_id) : bool {
return in_array($role_id, $this
->getRolesIds());
}
/**
* {@inheritdoc}
*/
public function hasPermission(string $permission) : bool {
// Blocked users do not have any permissions.
if ($this
->isBlocked()) {
return FALSE;
}
return (bool) array_filter($this
->getRoles(), function (OgRole $role) use ($permission) {
return $role
->hasPermission($permission);
});
}
/**
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields = [];
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(new TranslatableMarkup('ID'))
->setDescription(t("The group membership's unique ID."))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(new TranslatableMarkup('UUID'))
->setDescription(new TranslatableMarkup('The membership UUID.'))
->setReadOnly(TRUE);
$fields['type'] = BaseFieldDefinition::create('entity_reference')
->setLabel(new TranslatableMarkup('Type'))
->setDescription(new TranslatableMarkup('The bundle of the membership'))
->setSetting('target_type', 'og_membership_type');
$fields['uid'] = BaseFieldDefinition::create('entity_reference')
->setLabel(new TranslatableMarkup('Member User ID'))
->setDescription(new TranslatableMarkup('The user ID of the member.'))
->setSetting('target_type', 'user');
$fields['entity_type'] = BaseFieldDefinition::create('string')
->setLabel(new TranslatableMarkup('Group entity type'))
->setDescription(new TranslatableMarkup('The entity type of the group.'));
$fields['entity_bundle'] = BaseFieldDefinition::create('string')
->setLabel(new TranslatableMarkup('Group bundle ID'))
->setDescription(new TranslatableMarkup('The bundle ID of the group.'));
$fields['entity_id'] = BaseFieldDefinition::create('string')
->setLabel(new TranslatableMarkup('Group entity ID'))
->setDescription(new TranslatableMarkup('The entity ID of the group.'));
$fields['state'] = BaseFieldDefinition::create('string')
->setLabel(new TranslatableMarkup('State'))
->setDescription(new TranslatableMarkup('The user membership state: active, pending, or blocked.'))
->setDefaultValue(OgMembershipInterface::STATE_ACTIVE);
$fields['roles'] = BaseFieldDefinition::create('entity_reference')
->setLabel(new TranslatableMarkup('Roles'))
->setDescription(new TranslatableMarkup('The OG roles related to an OG membership entity.'))
->setCardinality(FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED)
->setDisplayOptions('view', [
'label' => 'hidden',
'type' => 'entity_reference_label',
'weight' => 0,
])
->setSetting('target_type', 'og_role');
$fields['created'] = BaseFieldDefinition::create('created')
->setLabel(new TranslatableMarkup('Create'))
->setDescription(new TranslatableMarkup('The Unix timestamp when the membership was created.'));
$fields['language'] = BaseFieldDefinition::create('language')
->setLabel(new TranslatableMarkup('Language'))
->setDescription(new TranslatableMarkup('The {languages}.language of this membership.'));
return $fields;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
// Check the value directly rather than using the entity, if there is one.
// This will watch actual empty values and '0'.
if (!($uid = $this
->get('uid')->target_id)) {
// Throw a generic logic exception as this will likely get caught in
// \Drupal\Core\Entity\Sql\SqlContentEntityStorage::save and turned into
// an EntityStorageException anyway.
throw new \LogicException('OG membership can not be created for an empty or anonymous user.');
}
if (!($entity_id = $this
->get('entity_id')->value)) {
// Group was not set.
throw new \LogicException('Membership cannot be set for an empty or an unsaved group.');
}
if (!($group = $this
->getGroup())) {
throw new \LogicException('A group entity is required for creating a membership.');
}
$entity_type_id = $group
->getEntityTypeId();
$bundle = $group
->bundle();
if (!Og::isGroup($entity_type_id, $bundle)) {
// Group is not valid.
throw new \LogicException(sprintf('Entity type %s with ID %s is not an OG group.', $entity_type_id, $group
->id()));
}
// Check if the roles are valid.
foreach ($this
->getRoles() as $role) {
/** @var \Drupal\og\Entity\OgRole $role */
// Make sure we don't save a membership for a non-member.
if ($role
->getName() == OgRoleInterface::ANONYMOUS) {
throw new \LogicException('Cannot save an OgMembership with reference to a non-member role.');
}
elseif ($role
->getName() == OgRoleInterface::AUTHENTICATED) {
$this
->revokeRole($role);
}
elseif (!$this
->isRoleValid($role)) {
throw new \LogicException(sprintf('The role with ID %s does not match the group type of the membership.', $role
->id()));
}
}
// Check for an existing membership.
$query = \Drupal::entityQuery('og_membership');
$query
->condition('uid', $uid)
->condition('entity_id', $entity_id)
->condition('entity_type', $this
->get('entity_type')->value);
if (!$this
->isNew()) {
// Filter out this membership.
$query
->condition('id', $this
->id(), '<>');
}
$count = $query
->range(0, 1)
->count()
->execute();
if ($count) {
throw new \LogicException(sprintf('An OG membership already exists for user ID %d and group of entity type %s and ID %s', $uid, $entity_type_id, $group
->id()));
}
parent::preSave($storage);
}
/**
* {@inheritdoc}
*/
public function save() {
$result = parent::save();
// Reset internal cache.
Og::reset();
return $result;
}
/**
* {@inheritdoc}
*/
protected function invalidateTagsOnSave($update) {
parent::invalidateTagsOnSave($update);
// A membership was created or updated: invalidate the membership list cache
// tags of its group. An updated membership may start to appear in a group's
// membership listings because it now meets those listings' filtering
// requirements. A newly created membership may start to appear in listings
// because it did not exist before.
$group = $this
->getGroup();
if (!empty($group)) {
$tags = Cache::buildTags(OgMembershipInterface::GROUP_MEMBERSHIP_LIST_CACHE_TAG_PREFIX, $group
->getCacheTagsToInvalidate());
Cache::invalidateTags($tags);
}
}
/**
* {@inheritdoc}
*/
protected static function invalidateTagsOnDelete(EntityTypeInterface $entity_type, array $entities) {
parent::invalidateTagsOnDelete($entity_type, $entities);
// A membership was deleted: invalidate the list cache tags of its group
// membership lists, so that any lists that contain the membership will be
// recalculated.
$tags = [];
foreach ($entities as $entity) {
if ($group = $entity
->getGroup()) {
$tags = Cache::mergeTags(Cache::buildTags(OgMembershipInterface::GROUP_MEMBERSHIP_LIST_CACHE_TAG_PREFIX, $group
->getCacheTagsToInvalidate()), $tags);
}
}
Cache::invalidateTags($tags);
}
/**
* {@inheritdoc}
*/
public static function create(array $values = []) {
// Use the default membership type by default.
$values += [
'type' => OgMembershipInterface::TYPE_DEFAULT,
];
return parent::create($values);
}
/**
* {@inheritdoc}
*/
public function isActive() : bool {
return $this
->getState() === OgMembershipInterface::STATE_ACTIVE;
}
/**
* {@inheritdoc}
*/
public function isPending() : bool {
return $this
->getState() === OgMembershipInterface::STATE_PENDING;
}
/**
* {@inheritdoc}
*/
public function isBlocked() : bool {
return $this
->getState() === OgMembershipInterface::STATE_BLOCKED;
}
/**
* {@inheritdoc}
*/
public function isOwner() : bool {
$group = $this
->getGroup();
return $group instanceof EntityOwnerInterface && $group
->getOwnerId() == $this
->getOwnerId();
}
/**
* Gets the value of a specific property of a field.
*
* Only the first delta can be accessed with this method.
*
* @todo Remove this once issue #2580551 is fixed.
*
* @see https://www.drupal.org/project/drupal/issues/2580551
*
* @param string $field_name
* The name of the field.
* @param string $property
* The field property, "value" for many field types.
*
* @return mixed
* The value.
*/
public function getFieldValue($field_name, $property) {
// Attempt to get the value from the values directly if the field is not
// initialized yet.
if (!isset($this->fields[$field_name])) {
$field_values = NULL;
if (isset($this->values[$field_name][$this->activeLangcode])) {
$field_values = $this->values[$field_name][$this->activeLangcode];
}
elseif (isset($this->values[$field_name][LanguageInterface::LANGCODE_DEFAULT])) {
$field_values = $this->values[$field_name][LanguageInterface::LANGCODE_DEFAULT];
}
if ($field_values !== NULL) {
// If there are field values, try to get the property value.
// Configurable/Multi-value fields are stored differently, try accessing
// with delta and property first, then without delta and last, if the
// value is a scalar, just return that.
if (isset($field_values[0][$property]) && is_array($field_values[0])) {
return $field_values[0][$property];
}
elseif (isset($field_values[$property]) && is_array($field_values)) {
return $field_values[$property];
}
elseif (!is_array($field_values)) {
return $field_values;
}
}
}
// Fall back to access the property through the field object.
return $this
->get($field_name)->{$property};
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
ContentEntityBase:: |
protected | property | Language code identifying the entity active language. | |
ContentEntityBase:: |
protected | property | Local cache for the default language code. | |
ContentEntityBase:: |
protected | property | The default langcode entity key. | |
ContentEntityBase:: |
protected | property | Whether the revision translation affected flag has been enforced. | |
ContentEntityBase:: |
protected | property | Holds untranslatable entity keys such as the ID, bundle, and revision ID. | |
ContentEntityBase:: |
protected | property | Local cache for field definitions. | |
ContentEntityBase:: |
protected | property | The array of fields, each being an instance of FieldItemListInterface. | |
ContentEntityBase:: |
protected static | property | Local cache for fields to skip from the checking for translation changes. | |
ContentEntityBase:: |
protected | property | Indicates whether this is the default revision. | |
ContentEntityBase:: |
protected | property | The language entity key. | |
ContentEntityBase:: |
protected | property | Local cache for the available language objects. | |
ContentEntityBase:: |
protected | property | The loaded revision ID before the new revision was set. | |
ContentEntityBase:: |
protected | property | Boolean indicating whether a new revision should be created on save. | |
ContentEntityBase:: |
protected | property | The revision translation affected entity key. | |
ContentEntityBase:: |
protected | property | Holds translatable entity keys such as the label. | |
ContentEntityBase:: |
protected | property | A flag indicating whether a translation object is being initialized. | |
ContentEntityBase:: |
protected | property | An array of entity translation metadata. | |
ContentEntityBase:: |
protected | property | Whether entity validation was performed. | |
ContentEntityBase:: |
protected | property | Whether entity validation is required before saving the entity. | |
ContentEntityBase:: |
protected | property | The plain data values of the contained fields. | |
ContentEntityBase:: |
public | function |
Checks data value access. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Adds a new translation to the translatable object. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
public static | function |
Provides field definitions for a specific bundle. Overrides FieldableEntityInterface:: |
4 |
ContentEntityBase:: |
protected | function | Clear entity translation object cache to remove stale references. | |
ContentEntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Gets a field item list. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets the value of the given entity key, if defined. | 1 |
ContentEntityBase:: |
public | function |
Gets the definition of a contained field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field definitions of all contained fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all field item lists. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Returns an array of field names to skip in ::hasTranslationChanges. | 1 |
ContentEntityBase:: |
public | function | ||
ContentEntityBase:: |
protected | function | ||
ContentEntityBase:: |
public | function |
Gets the loaded Revision ID of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the revision identifier of the entity. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of field item lists for translatable fields. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Gets a translated field. | |
ContentEntityBase:: |
public | function |
Gets a translation of the data. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the languages the data is translated to. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation status. Overrides TranslationStatusInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translatable object referring to the original language. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether the entity has a field with the given name. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks there is a translation for the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines if the current translation of the entity has unsaved changes. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the identifier. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Instantiates a translation object for an existing translation. | |
ContentEntityBase:: |
public | function |
Checks if this entity is the default revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is the default one. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if untranslatable fields should affect only the default translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if this entity is the latest revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether this is the latest revision affecting this translation. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Determines whether a new revision should be created on save. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the translation is new. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the current translation is affected by the current revision. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks if the revision translation affected flag value has been enforced. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Returns the translation support status. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets the label of the entity. Overrides EntityBase:: |
2 |
ContentEntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Reacts to changes to a field. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides EntityBase:: |
5 |
ContentEntityBase:: |
public | function |
Acts on a revision before it gets saved. Overrides RevisionableInterface:: |
2 |
ContentEntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityBase:: |
1 |
ContentEntityBase:: |
public | function |
Removes the translation identified by the given language code. Overrides TranslatableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets a field value. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
protected | function | Populates the local cache for the default language code. | |
ContentEntityBase:: |
public | function |
Enforces an entity to be saved as a new revision. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Marks the current revision translation as affected. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Enforces the revision translation affected flag value. Overrides TranslatableRevisionableInterface:: |
|
ContentEntityBase:: |
public | function |
Sets whether entity validation is required before saving the entity. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
|
ContentEntityBase:: |
protected | function | Updates language for already instantiated fields. | |
ContentEntityBase:: |
public | function |
Updates the loaded Revision ID with the revision ID. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Updates the original values with the interim changes. | |
ContentEntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function |
Validates the currently set values. Overrides FieldableEntityInterface:: |
|
ContentEntityBase:: |
public | function |
Checks whether the entity object was a default revision when it was saved. Overrides RevisionableInterface:: |
|
ContentEntityBase:: |
public | function | Magic method: Implements a deep clone. | |
ContentEntityBase:: |
public | function |
Constructs an Entity object. Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for getting object properties. | |
ContentEntityBase:: |
public | function | Implements the magic method for isset(). | |
ContentEntityBase:: |
public | function | Implements the magic method for setting object properties. | |
ContentEntityBase:: |
public | function |
Overrides EntityBase:: |
|
ContentEntityBase:: |
public | function | Implements the magic method for unset(). | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Determines whether the entity is new. Overrides EntityInterface:: |
2 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface:: |
16 |
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityInterface:: |
5 |
EntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public | function |
Sets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array of placeholders for this entity. | 2 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
EntityChangesDetectionTrait:: |
protected | function | Returns an array of field names to skip when checking for changes. Aliased as: traitGetFieldsToSkipFromTranslationChangesCheck | |
OgMembership:: |
public | function |
Adds a role to the user membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public static | function |
Provides base field definitions for an entity type. Overrides ContentEntityBase:: |
|
OgMembership:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityBase:: |
|
OgMembership:: |
public | function |
Gets the membership creation timestamp. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function | Gets the value of a specific property of a field. | |
OgMembership:: |
public | function |
Gets the group associated with the membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Gets the group entity bundle. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Gets the group entity type. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Gets the group entity ID. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Returns the entity owner's user entity. Overrides EntityOwnerInterface:: |
|
OgMembership:: |
public | function |
Returns the entity owner's user ID. Overrides EntityOwnerInterface:: |
|
OgMembership:: |
public | function |
Gets all the referenced OG roles. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Gets all the referenced OG role IDs. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Gets the membership state. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Gets the membership type. Overrides OgMembershipInterface:: |
|
OgMembership:: |
protected | function | Checks if a group has already been populated on the membership. | |
OgMembership:: |
public | function |
Checks if the user has a permission inside the group. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Checks if the membership has the role with the given ID. Overrides OgMembershipInterface:: |
|
OgMembership:: |
protected static | function |
Invalidates an entity's cache tags upon delete. Overrides EntityBase:: |
|
OgMembership:: |
protected | function |
Invalidates an entity's cache tags upon save. Overrides EntityBase:: |
|
OgMembership:: |
public | function |
Returns TRUE if the OG membership is active. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Returns TRUE if the OG membership is blocked. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Returns TRUE if the OG membership belongs to the group owner. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Returns TRUE if the OG membership is pending. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Returns whether the given role is valid for this membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides ContentEntityBase:: |
|
OgMembership:: |
public | function |
Revokes a role from the OG membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Revokes a role from the OG membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Saves an entity permanently. Overrides EntityBase:: |
|
OgMembership:: |
public | function |
Sets the membership creation timestamp. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Sets the group associated with the membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Sets the entity owner's user entity. Overrides EntityOwnerInterface:: |
|
OgMembership:: |
public | function |
Sets the entity owner's user ID. Overrides EntityOwnerInterface:: |
|
OgMembership:: |
public | function |
Sets the group's roles for the current user group membership. Overrides OgMembershipInterface:: |
|
OgMembership:: |
public | function |
Sets the membership state. Overrides OgMembershipInterface:: |
|
OgMembershipInterface:: |
constant | An array containing all possible group membership states. | ||
OgMembershipInterface:: |
constant | The prefix that is used to identify group membership list cache tags. | ||
OgMembershipInterface:: |
constant | The name of the user's request field in the default group membership type. | ||
OgMembershipInterface:: |
constant | Define active group content states. | ||
OgMembershipInterface:: |
constant | Define blocked group content states. The user is rejected from the group. | ||
OgMembershipInterface:: |
constant | Define pending group content states. | ||
OgMembershipInterface:: |
constant | The default group membership type that is the bundle of group membership. | ||
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
protected | property | Whether this entity is being created, updated or deleted through a synchronization process. | |
SynchronizableEntityTrait:: |
public | function | ||
SynchronizableEntityTrait:: |
public | function | ||
TranslationStatusInterface:: |
constant | Status code identifying a newly created translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying an existing translation. | ||
TranslationStatusInterface:: |
constant | Status code identifying a removed translation. |