Loading config/optional/views.view.subgroups.yml +6 −6 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ display: plugin_id: field view_group_content: id: view_group_content table: group_content table: group_relationship field: view_group_content relationship: group_content group_type: group Loading Loading @@ -320,7 +320,7 @@ display: plugin_id: entity_link edit_group_content: id: edit_group_content table: group_content table: group_relationship field: edit_group_content relationship: group_content group_type: group Loading Loading @@ -373,7 +373,7 @@ display: plugin_id: entity_link_edit delete_group_content: id: delete_group_content table: group_content table: group_relationship field: delete_group_content relationship: group_content group_type: group Loading Loading @@ -632,7 +632,7 @@ display: entity_field: type plugin_id: bundle sorts: { } title: Subgroups2 title: Subgroups header: { } footer: { } empty: { } Loading @@ -652,7 +652,7 @@ display: arguments: gid: id: gid table: group_content_field_data table: group_relationship_field_data field: gid relationship: group_content group_type: group Loading Loading @@ -705,7 +705,7 @@ display: position: 1 display_options: display_extenders: { } path: group/%group/subgroups2 path: group/%group/subgroups menu: type: tab title: Subgroups Loading ggroup.module +12 −10 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ */ use Drupal\group\Entity\GroupTypeInterface; use Drupal\group\Entity\GroupContentInterface; use Drupal\group\Entity\GroupRelationshipInterface; /** * Implements hook_entity_type_alter(). Loading @@ -15,35 +15,37 @@ 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'); $entity_types['group_content'] ->setLinkTemplate('subgroup_add_form', '/group/{group}/subgroup/create/{group_type}') ->setFormClass('ggroup-form', 'Drupal\ggroup\Form\SubgroupFormStep2') // Make sure circular references cannot be created with subgroups. $entity_types['group_content']->addConstraint('GroupSubgroup'); ->addConstraint('GroupSubgroup'); } /** * Implements hook_ENTITY_TYPE_insert(). */ function ggroup_group_type_insert(GroupTypeInterface $group_type) { \Drupal::service('plugin.manager.group_content_enabler')->clearCachedDefinitions(); \Drupal::service('group_relation_type.manager')->clearCachedDefinitions(); } /** * Implements hook_ENTITY_TYPE_insert(). */ function ggroup_group_content_insert(GroupContentInterface $group_content) { if ($group_content->getContentPlugin()->getEntityTypeId() !== 'group') { function ggroup_group_content_insert(GroupRelationshipInterface $group_relationship) { if ($group_relationship->getPlugin()->getRelationType()->getEntityTypeId() !== 'group') { return; } \Drupal::service('ggroup.group_hierarchy_manager')->addSubgroup($group_content); \Drupal::service('ggroup.group_hierarchy_manager')->addSubgroup($group_relationship); } /** * Implements hook_ENTITY_TYPE_delete(). */ function ggroup_group_content_delete(GroupContentInterface $group_content) { if ($group_content->getContentPlugin()->getEntityTypeId() !== 'group') { function ggroup_group_content_delete(GroupRelationshipInterface $group_content) { if ($group_content->getPlugin()->getRelationType()->getEntityTypeId() !== 'group') { return; } Loading ggroup.tokens.inc +9 −9 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ */ use Drupal\Core\Render\BubbleableMetadata; use Drupal\group\Entity\GroupContent; use Drupal\group\Entity\GroupRelationship; /** * Implements hook_token_info_alter(). Loading Loading @@ -51,15 +51,15 @@ function ggroup_tokens($type, $tokens, array $data, array $options, BubbleableMe $token_service = \Drupal::token(); $replacements = []; $group_content_array = GroupContent::loadByEntity($data['group']); if (empty($group_content_array)) { $group_relationship_array = GroupRelationship::loadByEntity($data['group']); if (empty($group_relationship_array)) { return []; } $groups = []; /** @var \Drupal\group\Entity\GroupContentInterface $group_content */ foreach ($group_content_array as $group_content) { $group = $group_content->getGroup(); /** @var \Drupal\group\Entity\GroupRelationshipInterface $group_relationship */ foreach ($group_relationship_array as $group_relationship) { $group = $group_relationship->getGroup(); $groups[$group->id()] = $group->label(); $bubbleable_metadata->addCacheableDependency($group); }; Loading @@ -73,9 +73,9 @@ function ggroup_tokens($type, $tokens, array $data, array $options, BubbleableMe $replacements += $token_service->generate('array', $parents_tokens, ['array' => $groups], $options, $bubbleable_metadata); } /** @var \Drupal\group\Entity\GroupContentInterface $group_content */ $group_content = array_pop($group_content_array); $group = $group_content->getGroup(); /** @var \Drupal\group\Entity\GroupRelationshipInterface $group_relationship */ $group_relationship = array_pop($group_relationship_array); $group = $group_relationship->getGroup(); if (isset($tokens['group'])) { $replacements[$tokens['group']] = $group->label(); } Loading ggroup.views.inc +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ function ggroup_views_data() { * Implements hook_views_data_alter(). */ function ggroup_views_data_alter(array &$data) { $data['group_content_field_data']['group_id_depth'] = [ $data['group_relationship_field_data']['group_id_depth'] = [ 'help' => t('Group id with depth implemented by subgroups'), 'argument' => [ 'title' => t('Has parent group ID (with depth)'), Loading src/Access/SubgroupAddAccessCheck.php +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class SubgroupAddAccessCheck implements AccessInterface { // We can only get the group content type ID if the plugin is installed. $plugin_id = "subgroup:{$group_type->id()}"; if (!$group->getGroupType()->hasContentPlugin($plugin_id)) { if (!$group->getGroupType()->hasPlugin($plugin_id)) { return AccessResult::neutral(); } Loading Loading
config/optional/views.view.subgroups.yml +6 −6 Original line number Diff line number Diff line Loading @@ -267,7 +267,7 @@ display: plugin_id: field view_group_content: id: view_group_content table: group_content table: group_relationship field: view_group_content relationship: group_content group_type: group Loading Loading @@ -320,7 +320,7 @@ display: plugin_id: entity_link edit_group_content: id: edit_group_content table: group_content table: group_relationship field: edit_group_content relationship: group_content group_type: group Loading Loading @@ -373,7 +373,7 @@ display: plugin_id: entity_link_edit delete_group_content: id: delete_group_content table: group_content table: group_relationship field: delete_group_content relationship: group_content group_type: group Loading Loading @@ -632,7 +632,7 @@ display: entity_field: type plugin_id: bundle sorts: { } title: Subgroups2 title: Subgroups header: { } footer: { } empty: { } Loading @@ -652,7 +652,7 @@ display: arguments: gid: id: gid table: group_content_field_data table: group_relationship_field_data field: gid relationship: group_content group_type: group Loading Loading @@ -705,7 +705,7 @@ display: position: 1 display_options: display_extenders: { } path: group/%group/subgroups2 path: group/%group/subgroups menu: type: tab title: Subgroups Loading
ggroup.module +12 −10 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ */ use Drupal\group\Entity\GroupTypeInterface; use Drupal\group\Entity\GroupContentInterface; use Drupal\group\Entity\GroupRelationshipInterface; /** * Implements hook_entity_type_alter(). Loading @@ -15,35 +15,37 @@ 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'); $entity_types['group_content'] ->setLinkTemplate('subgroup_add_form', '/group/{group}/subgroup/create/{group_type}') ->setFormClass('ggroup-form', 'Drupal\ggroup\Form\SubgroupFormStep2') // Make sure circular references cannot be created with subgroups. $entity_types['group_content']->addConstraint('GroupSubgroup'); ->addConstraint('GroupSubgroup'); } /** * Implements hook_ENTITY_TYPE_insert(). */ function ggroup_group_type_insert(GroupTypeInterface $group_type) { \Drupal::service('plugin.manager.group_content_enabler')->clearCachedDefinitions(); \Drupal::service('group_relation_type.manager')->clearCachedDefinitions(); } /** * Implements hook_ENTITY_TYPE_insert(). */ function ggroup_group_content_insert(GroupContentInterface $group_content) { if ($group_content->getContentPlugin()->getEntityTypeId() !== 'group') { function ggroup_group_content_insert(GroupRelationshipInterface $group_relationship) { if ($group_relationship->getPlugin()->getRelationType()->getEntityTypeId() !== 'group') { return; } \Drupal::service('ggroup.group_hierarchy_manager')->addSubgroup($group_content); \Drupal::service('ggroup.group_hierarchy_manager')->addSubgroup($group_relationship); } /** * Implements hook_ENTITY_TYPE_delete(). */ function ggroup_group_content_delete(GroupContentInterface $group_content) { if ($group_content->getContentPlugin()->getEntityTypeId() !== 'group') { function ggroup_group_content_delete(GroupRelationshipInterface $group_content) { if ($group_content->getPlugin()->getRelationType()->getEntityTypeId() !== 'group') { return; } Loading
ggroup.tokens.inc +9 −9 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ */ use Drupal\Core\Render\BubbleableMetadata; use Drupal\group\Entity\GroupContent; use Drupal\group\Entity\GroupRelationship; /** * Implements hook_token_info_alter(). Loading Loading @@ -51,15 +51,15 @@ function ggroup_tokens($type, $tokens, array $data, array $options, BubbleableMe $token_service = \Drupal::token(); $replacements = []; $group_content_array = GroupContent::loadByEntity($data['group']); if (empty($group_content_array)) { $group_relationship_array = GroupRelationship::loadByEntity($data['group']); if (empty($group_relationship_array)) { return []; } $groups = []; /** @var \Drupal\group\Entity\GroupContentInterface $group_content */ foreach ($group_content_array as $group_content) { $group = $group_content->getGroup(); /** @var \Drupal\group\Entity\GroupRelationshipInterface $group_relationship */ foreach ($group_relationship_array as $group_relationship) { $group = $group_relationship->getGroup(); $groups[$group->id()] = $group->label(); $bubbleable_metadata->addCacheableDependency($group); }; Loading @@ -73,9 +73,9 @@ function ggroup_tokens($type, $tokens, array $data, array $options, BubbleableMe $replacements += $token_service->generate('array', $parents_tokens, ['array' => $groups], $options, $bubbleable_metadata); } /** @var \Drupal\group\Entity\GroupContentInterface $group_content */ $group_content = array_pop($group_content_array); $group = $group_content->getGroup(); /** @var \Drupal\group\Entity\GroupRelationshipInterface $group_relationship */ $group_relationship = array_pop($group_relationship_array); $group = $group_relationship->getGroup(); if (isset($tokens['group'])) { $replacements[$tokens['group']] = $group->label(); } Loading
ggroup.views.inc +1 −1 Original line number Diff line number Diff line Loading @@ -23,7 +23,7 @@ function ggroup_views_data() { * Implements hook_views_data_alter(). */ function ggroup_views_data_alter(array &$data) { $data['group_content_field_data']['group_id_depth'] = [ $data['group_relationship_field_data']['group_id_depth'] = [ 'help' => t('Group id with depth implemented by subgroups'), 'argument' => [ 'title' => t('Has parent group ID (with depth)'), Loading
src/Access/SubgroupAddAccessCheck.php +1 −1 Original line number Diff line number Diff line Loading @@ -34,7 +34,7 @@ class SubgroupAddAccessCheck implements AccessInterface { // We can only get the group content type ID if the plugin is installed. $plugin_id = "subgroup:{$group_type->id()}"; if (!$group->getGroupType()->hasContentPlugin($plugin_id)) { if (!$group->getGroupType()->hasPlugin($plugin_id)) { return AccessResult::neutral(); } Loading