class GroupType in Group 8
Same name in this branch
- 8 src/Entity/GroupType.php \Drupal\group\Entity\GroupType
- 8 src/Plugin/Condition/GroupType.php \Drupal\group\Plugin\Condition\GroupType
Same name and namespace in other branches
- 2.0.x src/Entity/GroupType.php \Drupal\group\Entity\GroupType
Defines the Group type configuration entity.
Plugin annotation
@ConfigEntityType(
id = "group_type",
label = @Translation("Group type"),
label_singular = @Translation("group type"),
label_plural = @Translation("group types"),
label_count = @PluralTranslation(
singular = "@count group type",
plural = "@count group types"
),
handlers = {
"access" = "Drupal\group\Entity\Access\GroupTypeAccessControlHandler",
"form" = {
"add" = "Drupal\group\Entity\Form\GroupTypeForm",
"edit" = "Drupal\group\Entity\Form\GroupTypeForm",
"delete" = "Drupal\group\Entity\Form\GroupTypeDeleteForm"
},
"route_provider" = {
"html" = "Drupal\group\Entity\Routing\GroupTypeRouteProvider",
},
"list_builder" = "Drupal\group\Entity\Controller\GroupTypeListBuilder",
},
admin_permission = "administer group",
config_prefix = "type",
bundle_of = "group",
static_cache = TRUE,
entity_keys = {
"id" = "id",
"label" = "label"
},
links = {
"add-form" = "/admin/group/types/add",
"collection" = "/admin/group/types",
"content-plugins" = "/admin/group/types/manage/{group_type}/content",
"delete-form" = "/admin/group/types/manage/{group_type}/delete",
"edit-form" = "/admin/group/types/manage/{group_type}",
"permissions-form" = "/admin/group/types/manage/{group_type}/permissions"
},
config_export = {
"id",
"label",
"description",
"new_revision",
"creator_membership",
"creator_wizard",
"creator_roles",
}
)
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements ConfigEntityInterface uses SynchronizableEntityTrait, PluginDependencyTrait
- class \Drupal\Core\Config\Entity\ConfigEntityBundleBase
- class \Drupal\group\Entity\GroupType implements GroupTypeInterface
- class \Drupal\Core\Config\Entity\ConfigEntityBundleBase
- class \Drupal\Core\Config\Entity\ConfigEntityBase implements ConfigEntityInterface uses SynchronizableEntityTrait, PluginDependencyTrait
Expanded class hierarchy of GroupType
3 files declare their use of GroupType
- group.post_update.php in ./
group.post_update.php - Post update functions for Group.
- GroupContentEnablerBase.php in src/
Plugin/ GroupContentEnablerBase.php - GroupPermissions.php in src/
Access/ GroupPermissions.php
File
- src/
Entity/ GroupType.php, line 60
Namespace
Drupal\group\EntityView source
class GroupType extends ConfigEntityBundleBase implements GroupTypeInterface {
/**
* The machine name of the group type.
*
* @var string
*/
protected $id;
/**
* The human-readable name of the group type.
*
* @var string
*/
protected $label;
/**
* A brief description of the group type.
*
* @var string
*/
protected $description;
/**
* Whether a new revision should be created by default.
*
* @var bool
*/
protected $new_revision = TRUE;
/**
* The group creator automatically receives a membership.
*
* @var bool
*/
protected $creator_membership = TRUE;
/**
* The group creator must immediately complete their membership.
*
* @var bool
*/
protected $creator_wizard = TRUE;
/**
* The IDs of the group roles a group creator should receive.
*
* @var string[]
*/
protected $creator_roles = [];
/**
* {@inheritdoc}
*/
public function id() {
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getDescription() {
return $this->description;
}
/**
* {@inheritdoc}
*/
public function setDescription($description) {
$this->description = $description;
return $this;
}
/**
* {@inheritdoc}
*/
public function getRoles($include_internal = TRUE) {
$properties = [
'group_type' => $this
->id(),
];
// Exclude internal roles if told to.
if ($include_internal === FALSE) {
$properties['internal'] = FALSE;
}
return $this
->entityTypeManager()
->getStorage('group_role')
->loadByProperties($properties);
}
/**
* {@inheritdoc}
*/
public function getRoleIds($include_internal = TRUE) {
$query = $this
->entityTypeManager()
->getStorage('group_role')
->getQuery()
->condition('group_type', $this
->id());
// Exclude internal roles if told to.
if ($include_internal === FALSE) {
$query
->condition('internal', FALSE);
}
return $query
->execute();
}
/**
* {@inheritdoc}
*/
public function getAnonymousRole() {
return $this
->entityTypeManager()
->getStorage('group_role')
->load($this
->getAnonymousRoleId());
}
/**
* {@inheritdoc}
*/
public function getAnonymousRoleId() {
return $this
->id() . '-anonymous';
}
/**
* {@inheritdoc}
*/
public function getOutsiderRole() {
return $this
->entityTypeManager()
->getStorage('group_role')
->load($this
->getOutsiderRoleId());
}
/**
* {@inheritdoc}
*/
public function getOutsiderRoleId() {
return $this
->id() . '-outsider';
}
/**
* {@inheritdoc}
*/
public function getMemberRole() {
return $this
->entityTypeManager()
->getStorage('group_role')
->load($this
->getMemberRoleId());
}
/**
* {@inheritdoc}
*/
public function getMemberRoleId() {
return $this
->id() . '-member';
}
/**
* {@inheritdoc}
*/
public function shouldCreateNewRevision() {
return $this->new_revision;
}
/**
* {@inheritdoc}
*/
public function setNewRevision($new_revision) {
$this->new_revision = $new_revision;
}
/**
* {@inheritdoc}
*/
public function creatorGetsMembership() {
return $this->creator_membership;
}
/**
* {@inheritdoc}
*/
public function creatorMustCompleteMembership() {
return $this->creator_membership && $this->creator_wizard;
}
/**
* {@inheritdoc}
*/
public function getCreatorRoleIds() {
return $this->creator_roles;
}
/**
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage) {
// Throw an exception if the group type ID is longer than the limit.
if (strlen($this
->id()) > GroupTypeInterface::ID_MAX_LENGTH) {
throw new ConfigEntityIdLengthException("Attempt to create a group type with an ID longer than " . GroupTypeInterface::ID_MAX_LENGTH . " characters: {$this->id()}.");
}
parent::preSave($storage);
}
/**
* {@inheritdoc}
*/
public function postSave(EntityStorageInterface $storage, $update = TRUE) {
parent::postSave($storage, $update);
if (!$update) {
// Store the id in a short variable for readability.
$group_type_id = $this
->id();
// @todo Remove this line when https://www.drupal.org/node/2645202 lands.
$this
->setOriginalId($group_type_id);
// The code below will create the default group roles, synchronized group
// roles and the group content types for enforced plugins. It is extremely
// important that we only run this code when we're not dealing with config
// synchronization.
//
// Any of the config entities created here could still be queued up for
// import in a combined config import. Therefore, we only create them in
// \Drupal\group\EventSubscriber\ConfigSubscriber after the entire import
// has finished.
if (!$this
->isSyncing()) {
/** @var \Drupal\group\Entity\Storage\GroupRoleStorageInterface $group_role_storage */
$group_role_storage = $this
->entityTypeManager()
->getStorage('group_role');
// Enable enforced content plugins for the new group type.
$this
->getContentEnablerManager()
->installEnforced($this);
// Create internal and synchronized group roles for the new group type.
$group_role_storage
->createInternal([
$group_type_id,
]);
$group_role_storage
->createSynchronized([
$group_type_id,
]);
}
}
}
/**
* Returns the group role synchronizer service.
*
* @return \Drupal\group\GroupRoleSynchronizerInterface
* The group role synchronizer service.
*/
protected function getGroupRoleSynchronizer() {
return \Drupal::service('group_role.synchronizer');
}
/**
* Returns the content enabler plugin manager.
*
* @return \Drupal\group\Plugin\GroupContentEnablerManagerInterface
* The group content plugin manager.
*/
protected function getContentEnablerManager() {
return \Drupal::service('plugin.manager.group_content_enabler');
}
/**
* {@inheritdoc}
*/
public function getInstalledContentPlugins() {
return $this
->getContentEnablerManager()
->getInstalled($this);
}
/**
* {@inheritdoc}
*/
public function hasContentPlugin($plugin_id) {
$installed = $this
->getContentEnablerManager()
->getInstalledIds($this);
return in_array($plugin_id, $installed);
}
/**
* {@inheritdoc}
*/
public function getContentPlugin($plugin_id) {
return $this
->getInstalledContentPlugins()
->get($plugin_id);
}
}
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. | |
ConfigEntityBase:: |
private | property | Whether the config is being deleted by the uninstall process. | |
ConfigEntityBase:: |
protected | property | The language code of the entity's default language. | |
ConfigEntityBase:: |
protected | property | The original ID of the configuration entity. | |
ConfigEntityBase:: |
protected | property | The enabled/disabled status of the configuration entity. | 4 |
ConfigEntityBase:: |
protected | property | Third party entity settings. | |
ConfigEntityBase:: |
protected | property | Trust supplied data and not use configuration schema on save. | |
ConfigEntityBase:: |
protected | property | The UUID for this entity. | |
ConfigEntityBase:: |
protected | property | Information maintained by Drupal core about configuration. | |
ConfigEntityBase:: |
protected | function | Overrides \Drupal\Core\Entity\DependencyTrait:addDependency(). | |
ConfigEntityBase:: |
public | function |
Calculates dependencies and stores them in the dependency property. Overrides ConfigEntityInterface:: |
13 |
ConfigEntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityBase:: |
1 |
ConfigEntityBase:: |
public | function |
Disables the configuration entity. Overrides ConfigEntityInterface:: |
1 |
ConfigEntityBase:: |
public | function |
Enables the configuration entity. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Returns the value of a property. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityBase:: |
1 |
ConfigEntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityBase:: |
|
ConfigEntityBase:: |
protected static | function | Gets the configuration manager. | |
ConfigEntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Gets the configuration dependencies. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets the original ID. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Gets the list of third parties that store information. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets the value of a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets all third-party settings of a given module. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
protected | function | Gets the typed config manager. | |
ConfigEntityBase:: |
public | function |
Gets whether on not the data is trusted. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
protected static | function |
Override to never invalidate the individual entities' cache tags; the
config system already invalidates them. Overrides EntityBase:: |
|
ConfigEntityBase:: |
protected | function |
Override to never invalidate the entity's cache tag; the config system
already invalidates it. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Checks whether this entity is installable. Overrides ConfigEntityInterface:: |
2 |
ConfigEntityBase:: |
public | function |
Overrides Entity::isNew(). Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Returns whether this entity is being changed during the uninstall process. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Informs the entity that entities it depends on will be deleted. Overrides ConfigEntityInterface:: |
7 |
ConfigEntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityBase:: |
8 |
ConfigEntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityBase:: |
1 |
ConfigEntityBase:: |
public | function |
Sets the value of a property. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Sets the original ID. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Sets the status of the configuration entity. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Sets the value of a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function | ||
ConfigEntityBase:: |
public static | function | Helper callback for uasort() to sort configuration entities by weight and label. | 6 |
ConfigEntityBase:: |
public | function |
Returns whether the configuration entity is enabled. Overrides ConfigEntityInterface:: |
4 |
ConfigEntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityBase:: |
2 |
ConfigEntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Sets that the data should be trusted. Overrides ConfigEntityInterface:: |
|
ConfigEntityBase:: |
public | function |
Unsets a third-party setting. Overrides ThirdPartySettingsInterface:: |
|
ConfigEntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityBase:: |
|
ConfigEntityBase:: |
public | function |
Constructs an Entity object. Overrides EntityBase:: |
10 |
ConfigEntityBase:: |
public | function |
Overrides EntityBase:: |
4 |
ConfigEntityBundleBase:: |
protected | function | Deletes display if a bundle is deleted. | |
ConfigEntityBundleBase:: |
protected | function | Returns view or form displays for this bundle. | |
ConfigEntityBundleBase:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityBase:: |
2 |
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 | |
DependencyTrait:: |
protected | property | The object's dependencies. | |
DependencyTrait:: |
protected | function | Adds multiple dependencies. | |
DependencyTrait:: |
protected | function | Adds a dependency. Aliased as: addDependencyTrait | |
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 |
Checks data value access. Overrides AccessibleInterface:: |
1 |
EntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
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 |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
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 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 |
Gets the label of the entity. Overrides EntityInterface:: |
6 |
EntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the language manager. | |
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 | function |
Acts on a created entity before hooks are invoked. Overrides EntityInterface:: |
4 |
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 | function |
Gets a list of entities referenced by this entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets an array of placeholders for this entity. | 2 |
EntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
GroupType:: |
protected | property | The group creator automatically receives a membership. | |
GroupType:: |
protected | property | The IDs of the group roles a group creator should receive. | |
GroupType:: |
protected | property | The group creator must immediately complete their membership. | |
GroupType:: |
protected | property | A brief description of the group type. | |
GroupType:: |
protected | property | The machine name of the group type. | |
GroupType:: |
protected | property | The human-readable name of the group type. | |
GroupType:: |
protected | property | Whether a new revision should be created by default. | |
GroupType:: |
public | function |
Returns whether the group creator automatically receives a membership. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Returns whether the group creator must complete their membership. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the generic anonymous group role for this group type. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the generic anonymous role ID. Overrides GroupTypeInterface:: |
|
GroupType:: |
protected | function | Returns the content enabler plugin manager. | |
GroupType:: |
public | function |
Gets an installed content enabler plugin for this group type. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the IDs of the group roles a group creator should receive. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the entity description. Overrides EntityDescriptionInterface:: |
|
GroupType:: |
protected | function | Returns the group role synchronizer service. | |
GroupType:: |
public | function |
Returns the installed content enabler plugins for this group type. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the generic member group role for this group type. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the generic member role ID. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the generic outsider group role for this group type. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the generic outsider role ID. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the role IDs. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the group roles. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Checks whether a content enabler plugin is installed for this group type. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets the identifier. Overrides EntityBase:: |
|
GroupType:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides ConfigEntityBundleBase:: |
|
GroupType:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides ConfigEntityBundleBase:: |
|
GroupType:: |
public | function |
Sets the entity description. Overrides EntityDescriptionInterface:: |
|
GroupType:: |
public | function |
Sets whether a new revision should be created by default. Overrides GroupTypeInterface:: |
|
GroupType:: |
public | function |
Gets whether a new revision should be created by default. Overrides RevisionableEntityBundleInterface:: |
|
GroupTypeInterface:: |
constant | The maximum length of the ID, in characters. | ||
PluginDependencyTrait:: |
protected | function | Calculates and adds dependencies of a specific plugin instance. | 1 |
PluginDependencyTrait:: |
protected | function | Calculates and returns dependencies of a specific plugin instance. | |
PluginDependencyTrait:: |
protected | function | Wraps the module handler. | 1 |
PluginDependencyTrait:: |
protected | function | Wraps the theme handler. | 1 |
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 |