Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #402 from mariano-dagostino/372-remove-getAllGroup…
Browse files Browse the repository at this point in the history
…Bundles

Remove getAllGroupBundles and replace with getGroupMap
  • Loading branch information
pfrenssen authored Aug 10, 2020
2 parents 73f7117 + 023f9d0 commit 54c30ab
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 36 deletions.
2 changes: 1 addition & 1 deletion og_ui/src/BundleFormAlter.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected function addGroupContent(array &$form, FormStateInterface $form_state)
// Compile a list of group entity types and bundles.
$target_types = [];
$target_bundles = [];
foreach (Og::groupTypeManager()->getAllGroupBundles() as $entity_type => $bundles) {
foreach (Og::groupTypeManager()->getGroupMap() as $entity_type => $bundles) {
$target_types[$entity_type] = \Drupal::entityTypeManager()->getDefinition($entity_type)->getLabel();
$bundle_info = \Drupal::service('entity_type.bundle.info')->getBundleInfo($entity_type);
foreach ($bundles as $bundle) {
Expand Down
2 changes: 1 addition & 1 deletion og_ui/src/Controller/OgUiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function rolesPermissionsOverviewPage($type) {
$rows = [];
$build = [];

foreach ($this->groupTypeManager->getAllGroupBundles() as $entity_type => $bundles) {
foreach ($this->groupTypeManager->getGroupMap() as $entity_type => $bundles) {
$definition = $this->entityTypeManager->getDefinition($entity_type);
$bundle_info = $this->entityTypeBundleInfo->getBundleInfo($entity_type);
foreach ($bundles as $bundle) {
Expand Down
8 changes: 0 additions & 8 deletions src/GroupTypeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,6 @@ public function getGroupBundleIdsByEntityType($entity_type_id) {
return isset($group_map[$entity_type_id]) ? $group_map[$entity_type_id] : [];
}

/**
* {@inheritdoc}
*/
public function getAllGroupBundles($entity_type = NULL) {
$group_map = $this->getGroupMap();
return !empty($group_map[$entity_type]) ? $group_map[$entity_type] : $group_map;
}

/**
* {@inheritdoc}
*/
Expand Down
9 changes: 0 additions & 9 deletions src/GroupTypeManagerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@ public function isGroupContent($entity_type_id, $bundle);
*/
public function getGroupBundleIdsByEntityType($entity_type_id);

/**
* Get all group bundles keyed by entity type.
*
* @return string[][]
* An associative array, keyed by entity type, each value an indexed array
* of bundle IDs.
*/
public function getAllGroupBundles($entity_type = NULL);

/**
* Returns a list of all group content bundles IDs keyed by entity type.
*
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/Condition/GroupType.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function create(ContainerInterface $container, array $configuratio
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$options = [];
$group_types = $this->groupTypeManager->getAllGroupBundles();
$group_types = $this->groupTypeManager->getGroupMap();

// If no groups have been created yet, show only the error message and hide
// the other elements.
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/EntityReferenceSelection/OgSelection.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS')
$definition = \Drupal::entityTypeManager()->getDefinition($target_type);

if ($bundle_key = $definition->getKey('bundle')) {
$bundles = Og::groupTypeManager()->getAllGroupBundles($target_type);
$bundles = Og::groupTypeManager()->getGroupBundleIdsByEntityType($target_type);

if (!$bundles) {
// If there are no bundles defined, we can return early.
Expand Down
15 changes: 0 additions & 15 deletions tests/src/Unit/GroupTypeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,21 +154,6 @@ public function testInstance() {
$this->assertInstanceOf(GroupTypeManagerInterface::class, $group_manager);
}

/**
* Tests getting all the group bundles.
*
* @covers ::getAllGroupBundles
*/
public function testGetAllGroupBundles() {
// It is expected that the group map will be retrieved from config.
$groups = ['test_entity' => ['a', 'b']];
$this->expectGroupMapRetrieval($groups);

$manager = $this->createGroupManager();

$this->assertSame($groups, $manager->getAllGroupBundles());
}

/**
* Tests checking if an entity is a group.
*
Expand Down

0 comments on commit 54c30ab

Please sign in to comment.