ggroup.module in Subgroup (Graph) 1.0.x
Enables Subgroup functionality.
File
ggroup.moduleView source
<?php
/**
* @file
* Enables Subgroup functionality.
*/
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\Entity\GroupContentInterface;
/**
* Implements hook_entity_type_alter().
*/
function ggroup_entity_type_alter(array &$entity_types) {
/** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
// Add the subgroup creation wizard steps as entity forms.
$entity_types['group']
->setFormClass('ggroup-form', 'Drupal\\ggroup\\Form\\SubgroupFormStep1');
$entity_types['group_content']
->setFormClass('ggroup-form', 'Drupal\\ggroup\\Form\\SubgroupFormStep2');
// Make sure circular references cannot be created with subgroups.
$entity_types['group_content']
->addConstraint('GroupSubgroup');
}
/**
* Implements hook_ENTITY_TYPE_insert().
*/
function ggroup_group_type_insert(GroupTypeInterface $group_type) {
\Drupal::service('plugin.manager.group_content_enabler')
->clearCachedDefinitions();
}
/**
* Implements hook_ENTITY_TYPE_insert().
*/
function ggroup_group_content_insert(GroupContentInterface $group_content) {
if ($group_content
->getContentPlugin()
->getEntityTypeId() !== 'group') {
return;
}
\Drupal::service('ggroup.group_hierarchy_manager')
->addSubgroup($group_content);
}
/**
* Implements hook_ENTITY_TYPE_delete().
*/
function ggroup_group_content_delete(GroupContentInterface $group_content) {
if ($group_content
->getContentPlugin()
->getEntityTypeId() !== 'group') {
return;
}
\Drupal::service('ggroup.group_hierarchy_manager')
->removeSubgroup($group_content);
}
Functions
Name | Description |
---|---|
ggroup_entity_type_alter | Implements hook_entity_type_alter(). |
ggroup_group_content_delete | Implements hook_ENTITY_TYPE_delete(). |
ggroup_group_content_insert | Implements hook_ENTITY_TYPE_insert(). |
ggroup_group_type_insert | Implements hook_ENTITY_TYPE_insert(). |