From 02c056c890c67a68efe59c421dc3729b61f0d375 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Fri, 22 Sep 2023 21:11:25 +0530 Subject: [PATCH 01/13] Enhancements for adding filter with ChannelId on condition --- .../src/Form/TeamAliasForm.php | 10 ++++++++- ...dPaginatedEntityListingControllerTrait.php | 22 ++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/modules/apigee_edge_teams/src/Form/TeamAliasForm.php b/modules/apigee_edge_teams/src/Form/TeamAliasForm.php index 97d392a8..2056bbf0 100644 --- a/modules/apigee_edge_teams/src/Form/TeamAliasForm.php +++ b/modules/apigee_edge_teams/src/Form/TeamAliasForm.php @@ -68,6 +68,13 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $config->get('channelid'), '#description' => $this->t('Leave empty to use the default "@channelid" as channel ID.', ['@channelid' => $this->originalChannelId()]), ]; + + $form['channel_label']['enablefilter'] = [ + '#type' => 'checkbox', + '#title' => $this->t('Filter by Channel ID'), + '#default_value' => $config->get('enablefilter'), + '#description' => $this->t('Enables the filter with Channel ID for AppGroups listing'), + ]; } return parent::buildForm($form, $form_state); } @@ -97,9 +104,10 @@ public function validateForm(array &$form, FormStateInterface $form_state) { public function submitForm(array &$form, FormStateInterface $form_state) { $config = $this->config($this->getConfigNameWithLabels()); - if ($config->get('team_prefix') !== $form_state->getValue('team_prefix') || $config->get('channelid') !== $form_state->getValue('channelid')) { + if ($config->get('team_prefix') !== $form_state->getValue('team_prefix') || $config->get('channelid') !== $form_state->getValue('channelid') || $config->get('enablefilter') !== $form_state->getValue('enablefilter')) { $config->set('team_prefix', $form_state->getValue('team_prefix')) ->set('channelid', $form_state->getValue('channelid')) + ->set('enablefilter', $form_state->getValue('enablefilter')) ->save(); } diff --git a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php index 190d5194..7a466592 100644 --- a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php +++ b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php @@ -55,7 +55,27 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = } } - $entities = $this->decorated()->getEntities($pager, $key_provider); + // Getting the channelId & filter enable check from Config form. + $channelconfig = \Drupal::config('apigee_edge_teams.team_settings'); + $channelid = $channelconfig->get('channelid'); + $channelfilter = $channelconfig->get('enablefilter'); + + if ($channelfilter) { + if ($channelid) { + $queryparam = [ + 'filter' => 'channelId=' . $channelid, + ]; + } + else { + $queryparam = [ + 'filter' => 'channelId=devportal', + ]; + } + $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); + } + else { + $entities = $this->decorated()->getEntities($pager, $key_provider); + } $this->entityCache()->saveEntities($entities); if ($pager === NULL) { $this->entityCache()->allEntitiesInCache(TRUE); From dd9219fa899bded77916cacada2a753023e57498 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Tue, 26 Sep 2023 19:37:07 +0530 Subject: [PATCH 02/13] Changes for overriding the getEntities function for Teams Listing --- .../src/Entity/Controller/TeamController.php | 48 +++++++++++++++++++ ...dPaginatedEntityListingControllerTrait.php | 22 +-------- 2 files changed, 49 insertions(+), 21 deletions(-) diff --git a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php index b9243917..b01eb616 100644 --- a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php +++ b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php @@ -25,6 +25,7 @@ use Apigee\Edge\Api\Management\Controller\CompanyController as EdgeCompanyController; use Apigee\Edge\Api\Management\Controller\CompanyControllerInterface as EdgeCompanyControllerInterface; use Apigee\Edge\Entity\EntityInterface; +use Apigee\Edge\Structure\PagerInterface; use Drupal\apigee_edge\Entity\Controller\Cache\AppCacheByOwnerFactoryInterface; use Drupal\apigee_edge\Entity\Controller\Cache\AppNameCacheByOwnerFactoryInterface; use Drupal\apigee_edge\Entity\Controller\Cache\EntityCacheInterface; @@ -233,4 +234,51 @@ public function delete(string $entity_id): EntityInterface { return $entity; } + /** + * {@inheritdoc} + */ + public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id'): array { + if ($this->entityCache()->isAllEntitiesInCache()) { + if ($pager === NULL) { + return $this->entityCache()->getEntities(); + } + else { + return $this->extractSubsetOfAssociativeArray($this->entityCache()->getEntities(), $pager->getLimit(), $pager->getStartKey()); + } + } + + if ($this->orgController->isOrganizationApigeeX()) { + // Getting the channelId & filter enable check from Config form. + $channelconfig = \Drupal::config('apigee_edge_teams.team_settings'); + $channelid = $channelconfig->get('channelid'); + $channelfilter = $channelconfig->get('enablefilter'); + + if ($channelfilter) { + if ($channelid) { + $queryparam = [ + 'filter' => 'channelId=' . $channelid, + ]; + } + else { + $queryparam = [ + 'filter' => 'channelId=devportal', + ]; + } + $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); + } + else { + $entities = $this->decorated()->getEntities($pager, $key_provider); + } + } + else { + $entities = $this->decorated()->getEntities($pager, $key_provider); + } + $this->entityCache()->saveEntities($entities); + if ($pager === NULL) { + $this->entityCache()->allEntitiesInCache(TRUE); + } + + return $entities; + } + } diff --git a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php index 7a466592..190d5194 100644 --- a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php +++ b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php @@ -55,27 +55,7 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = } } - // Getting the channelId & filter enable check from Config form. - $channelconfig = \Drupal::config('apigee_edge_teams.team_settings'); - $channelid = $channelconfig->get('channelid'); - $channelfilter = $channelconfig->get('enablefilter'); - - if ($channelfilter) { - if ($channelid) { - $queryparam = [ - 'filter' => 'channelId=' . $channelid, - ]; - } - else { - $queryparam = [ - 'filter' => 'channelId=devportal', - ]; - } - $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); - } - else { - $entities = $this->decorated()->getEntities($pager, $key_provider); - } + $entities = $this->decorated()->getEntities($pager, $key_provider); $this->entityCache()->saveEntities($entities); if ($pager === NULL) { $this->entityCache()->allEntitiesInCache(TRUE); From c79ff62998644ccf88da794ea691f988ddcf9730 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Wed, 4 Oct 2023 18:35:10 +0530 Subject: [PATCH 03/13] Changes for Unittest cases and updates --- .../src/Entity/Controller/TeamController.php | 4 +++- modules/apigee_edge_teams/src/Form/TeamAliasForm.php | 2 +- modules/apigee_edge_teams/tests/src/Functional/UiTest.php | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php index b01eb616..31bdaf1a 100644 --- a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php +++ b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php @@ -39,6 +39,7 @@ use Drupal\apigee_edge\Entity\DeveloperCompaniesCacheInterface; use Drupal\apigee_edge\SDKConnectorInterface; use Drupal\apigee_edge_teams\CompanyMembershipObjectCacheInterface; +use Drupal\apigee_edge_teams\Form\TeamAliasForm; /** * Definition of the Team controller service. @@ -260,8 +261,9 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = ]; } else { + $defaultChannelId = TeamAliasForm::originalChannelId(); $queryparam = [ - 'filter' => 'channelId=devportal', + 'filter' => 'channelId=' . $defaultChannelId, ]; } $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); diff --git a/modules/apigee_edge_teams/src/Form/TeamAliasForm.php b/modules/apigee_edge_teams/src/Form/TeamAliasForm.php index 2056bbf0..cd785910 100644 --- a/modules/apigee_edge_teams/src/Form/TeamAliasForm.php +++ b/modules/apigee_edge_teams/src/Form/TeamAliasForm.php @@ -73,7 +73,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#type' => 'checkbox', '#title' => $this->t('Filter by Channel ID'), '#default_value' => $config->get('enablefilter'), - '#description' => $this->t('Enables the filter with Channel ID for AppGroups listing'), + '#description' => $this->t('Enforce the filtering of AppGroups based on Channel ID specified in the field above.'), ]; } return parent::buildForm($form, $form_state); diff --git a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php index 494ecf86..79a53ed3 100644 --- a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php +++ b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php @@ -309,9 +309,11 @@ protected function teamsWorkflowTest() { * Tests the team entity label modifications. */ protected function teamAndTeamAppLabelTest() { + $team_name = mb_strtolower($this->getRandomGenerator()->name()); + $team_app_1_name = mb_strtolower($this->getRandomGenerator()->name()); $this->drupalLogin($this->rootUser); - $this->changeEntityAliasesAndValidate('team', 'apigee_edge_teams.settings.team'); - $this->changeEntityAliasesAndValidate('team_app', 'apigee_edge_teams.settings.team_app'); + $this->changeEntityAliasesAndValidate($team_name, 'apigee_edge_teams.settings.team'); + $this->changeEntityAliasesAndValidate($team_app_1_name, 'apigee_edge_teams.settings.team_app'); } /** From 2529e830ed47cefdcbc95abae61516f6bc6e9179 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Wed, 4 Oct 2023 19:24:49 +0530 Subject: [PATCH 04/13] Changes for Unittest cases --- .../tests/src/Functional/UiTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php index 79a53ed3..58addc08 100644 --- a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php +++ b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php @@ -152,14 +152,16 @@ protected function tearDown(): void { * Tests the UI of the team and team app entities. */ public function testUi() { - $this->teamsWorkflowTest(); - $this->teamAndTeamAppLabelTest(); + $team_name = mb_strtolower($this->getRandomGenerator()->name()); + $team_app_1_name = mb_strtolower($this->getRandomGenerator()->name()); + $this->teamsWorkflowTest($team_name, $team_app_1_name); + $this->teamAndTeamAppLabelTest($team_name, $team_app_1_name); } /** * Tests CRUD UIs of team and team app entities. */ - protected function teamsWorkflowTest() { + protected function teamsWorkflowTest($team_name, $team_app_1_name) { $this->drupalLogin($this->account); // Open team collection page. $this->drupalGet(Url::fromRoute('entity.team.collection')); @@ -167,7 +169,7 @@ protected function teamsWorkflowTest() { // Create a new team and check whether the link to the team is visible on // the listing page. $this->clickLink('Add team'); - $team_name = $team_display_name = mb_strtolower($this->getRandomGenerator()->name()); + $team_display_name = $team_name; $this->submitForm([ 'name' => $team_name, 'displayName[0][value]' => $team_display_name, @@ -223,7 +225,7 @@ protected function teamsWorkflowTest() { $this->assertSession()->pageTextContains('There are no team apps yet.'); $this->clickLink('Add team app'); - $team_app_1_name = $team_app_1_display_name = mb_strtolower($this->getRandomGenerator()->name()); + $team_app_1_display_name = $team_app_1_name; $this->submitForm([ 'name' => $team_app_1_name, 'displayName[0][value]' => $team_app_1_display_name, @@ -308,9 +310,7 @@ protected function teamsWorkflowTest() { /** * Tests the team entity label modifications. */ - protected function teamAndTeamAppLabelTest() { - $team_name = mb_strtolower($this->getRandomGenerator()->name()); - $team_app_1_name = mb_strtolower($this->getRandomGenerator()->name()); + protected function teamAndTeamAppLabelTest($team_name, $team_app_1_name) { $this->drupalLogin($this->rootUser); $this->changeEntityAliasesAndValidate($team_name, 'apigee_edge_teams.settings.team'); $this->changeEntityAliasesAndValidate($team_app_1_name, 'apigee_edge_teams.settings.team_app'); From 14f29d8f159e2cd96d7f6c6f077d92d1bd19372d Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Wed, 4 Oct 2023 21:11:21 +0530 Subject: [PATCH 05/13] Changes for failing Unit tests --- .../tests/src/Functional/UiTest.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php index 58addc08..b78c38fb 100644 --- a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php +++ b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php @@ -152,16 +152,14 @@ protected function tearDown(): void { * Tests the UI of the team and team app entities. */ public function testUi() { - $team_name = mb_strtolower($this->getRandomGenerator()->name()); - $team_app_1_name = mb_strtolower($this->getRandomGenerator()->name()); - $this->teamsWorkflowTest($team_name, $team_app_1_name); - $this->teamAndTeamAppLabelTest($team_name, $team_app_1_name); + $this->teamsWorkflowTest(); + $this->teamAndTeamAppLabelTest(); } /** * Tests CRUD UIs of team and team app entities. */ - protected function teamsWorkflowTest($team_name, $team_app_1_name) { + protected function teamsWorkflowTest() { $this->drupalLogin($this->account); // Open team collection page. $this->drupalGet(Url::fromRoute('entity.team.collection')); @@ -169,7 +167,7 @@ protected function teamsWorkflowTest($team_name, $team_app_1_name) { // Create a new team and check whether the link to the team is visible on // the listing page. $this->clickLink('Add team'); - $team_display_name = $team_name; + $team_name = $team_display_name = mb_strtolower($this->getRandomGenerator()->name()); $this->submitForm([ 'name' => $team_name, 'displayName[0][value]' => $team_display_name, @@ -225,7 +223,7 @@ protected function teamsWorkflowTest($team_name, $team_app_1_name) { $this->assertSession()->pageTextContains('There are no team apps yet.'); $this->clickLink('Add team app'); - $team_app_1_display_name = $team_app_1_name; + $team_app_1_name = $team_app_1_display_name = mb_strtolower($this->getRandomGenerator()->name());; $this->submitForm([ 'name' => $team_app_1_name, 'displayName[0][value]' => $team_app_1_display_name, @@ -310,10 +308,10 @@ protected function teamsWorkflowTest($team_name, $team_app_1_name) { /** * Tests the team entity label modifications. */ - protected function teamAndTeamAppLabelTest($team_name, $team_app_1_name) { + protected function teamAndTeamAppLabelTest() { $this->drupalLogin($this->rootUser); - $this->changeEntityAliasesAndValidate($team_name, 'apigee_edge_teams.settings.team'); - $this->changeEntityAliasesAndValidate($team_app_1_name, 'apigee_edge_teams.settings.team_app'); + $this->changeEntityAliasesAndValidate('team', 'apigee_edge_teams.settings.team'); + $this->changeEntityAliasesAndValidate('team_app', 'apigee_edge_teams.settings.team_app'); } /** From 9645c969fdaa3bd7cbdedb8591ec7d4df0470944 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Wed, 4 Oct 2023 21:21:36 +0530 Subject: [PATCH 06/13] Changes for PHPCS --- modules/apigee_edge_teams/tests/src/Functional/UiTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php index b78c38fb..494ecf86 100644 --- a/modules/apigee_edge_teams/tests/src/Functional/UiTest.php +++ b/modules/apigee_edge_teams/tests/src/Functional/UiTest.php @@ -223,7 +223,7 @@ protected function teamsWorkflowTest() { $this->assertSession()->pageTextContains('There are no team apps yet.'); $this->clickLink('Add team app'); - $team_app_1_name = $team_app_1_display_name = mb_strtolower($this->getRandomGenerator()->name());; + $team_app_1_name = $team_app_1_display_name = mb_strtolower($this->getRandomGenerator()->name()); $this->submitForm([ 'name' => $team_app_1_name, 'displayName[0][value]' => $team_app_1_display_name, From 7a798e9846c790e7fc1120e369ffc702587f96e1 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Thu, 5 Oct 2023 16:50:47 +0530 Subject: [PATCH 07/13] Update the schema --- .../apigee_edge_teams/apigee_edge_teams.install | 15 +++++++++++++++ .../install/apigee_edge_teams.team_settings.yml | 1 + .../config/schema/apigee_edge_teams.schema.yml | 3 +++ 3 files changed, 19 insertions(+) diff --git a/modules/apigee_edge_teams/apigee_edge_teams.install b/modules/apigee_edge_teams/apigee_edge_teams.install index d0a83c20..9fa5a30c 100644 --- a/modules/apigee_edge_teams/apigee_edge_teams.install +++ b/modules/apigee_edge_teams/apigee_edge_teams.install @@ -218,3 +218,18 @@ function apigee_edge_teams_update_9002() { $team_settings['content']['callbackUrl'] = $new_team_settings['content']['callbackUrl']; $config_storage->write('core.entity_view_display.team_app.team_app.default', $team_settings); } + +/** + * Install Configs for TeamAlias Form for Teams Setting Page + */ +function apigee_edge_teams_update_9003() { + // Update existing config. + /** @var \Drupal\Core\Config\StorageInterface $config_storage */ + $config_storage = \Drupal::service('config.storage'); + $module_path = \Drupal::service('extension.list.module')->getPath('apigee_edge_teams'); + $source = new FileStorage("$module_path/config/install"); + $new_team_settings = $source->read('apigee_edge_teams.team_settings'); + $team_settings = $config_storage->read('apigee_edge_teams.team_settings'); + $team_settings['enablefilter'] = $new_team_settings['enablefilter']; + $config_storage->write('apigee_edge_teams.team_settings', $team_settings); +} diff --git a/modules/apigee_edge_teams/config/install/apigee_edge_teams.team_settings.yml b/modules/apigee_edge_teams/config/install/apigee_edge_teams.team_settings.yml index 388d93e3..fda69532 100644 --- a/modules/apigee_edge_teams/config/install/apigee_edge_teams.team_settings.yml +++ b/modules/apigee_edge_teams/config/install/apigee_edge_teams.team_settings.yml @@ -1,6 +1,7 @@ langcode: en team_prefix: '' channelid: '' +enablefilter: '' entity_label_singular: '' entity_label_plural: '' cache_expiration: 900 diff --git a/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml b/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml index 69f5d137..f1a2a0d0 100644 --- a/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml +++ b/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml @@ -8,6 +8,9 @@ apigee_edge_teams.team_settings: channelid: type: label label: 'ChannelId settings' + enablefilter: + type: checkbox + label: 'Filter by Channel ID' entity_label_singular: type: label label: 'How to refer to a Team on the UI (singular)' From 52f7cf1af892ce3328c130c704131dcf3986de33 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Thu, 5 Oct 2023 17:40:33 +0530 Subject: [PATCH 08/13] Update the Config schema --- .../config/schema/apigee_edge_teams.schema.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml b/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml index f1a2a0d0..2a4df60a 100644 --- a/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml +++ b/modules/apigee_edge_teams/config/schema/apigee_edge_teams.schema.yml @@ -9,7 +9,7 @@ apigee_edge_teams.team_settings: type: label label: 'ChannelId settings' enablefilter: - type: checkbox + type: label label: 'Filter by Channel ID' entity_label_singular: type: label From d9922dd779b1f1c6cbcc5c9e22c3f5370d815211 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Thu, 5 Oct 2023 19:21:28 +0530 Subject: [PATCH 09/13] Removed changes for entitycache as it is not required --- .../src/Entity/Controller/TeamController.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php index 31bdaf1a..efb99d9a 100644 --- a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php +++ b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php @@ -239,15 +239,6 @@ public function delete(string $entity_id): EntityInterface { * {@inheritdoc} */ public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id'): array { - if ($this->entityCache()->isAllEntitiesInCache()) { - if ($pager === NULL) { - return $this->entityCache()->getEntities(); - } - else { - return $this->extractSubsetOfAssociativeArray($this->entityCache()->getEntities(), $pager->getLimit(), $pager->getStartKey()); - } - } - if ($this->orgController->isOrganizationApigeeX()) { // Getting the channelId & filter enable check from Config form. $channelconfig = \Drupal::config('apigee_edge_teams.team_settings'); @@ -275,10 +266,6 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = else { $entities = $this->decorated()->getEntities($pager, $key_provider); } - $this->entityCache()->saveEntities($entities); - if ($pager === NULL) { - $this->entityCache()->allEntitiesInCache(TRUE); - } return $entities; } From 73acdb90d987bcabb07c0f6cf7b53c4bd8e0354d Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Mon, 9 Oct 2023 16:03:24 +0530 Subject: [PATCH 10/13] Requested changes updated --- .../src/Entity/Controller/TeamController.php | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php index efb99d9a..848c9e67 100644 --- a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php +++ b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php @@ -239,34 +239,18 @@ public function delete(string $entity_id): EntityInterface { * {@inheritdoc} */ public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id'): array { + $queryparam = []; if ($this->orgController->isOrganizationApigeeX()) { // Getting the channelId & filter enable check from Config form. $channelconfig = \Drupal::config('apigee_edge_teams.team_settings'); $channelid = $channelconfig->get('channelid'); $channelfilter = $channelconfig->get('enablefilter'); - + $defaultChannelId = TeamAliasForm::originalChannelId(); if ($channelfilter) { - if ($channelid) { - $queryparam = [ - 'filter' => 'channelId=' . $channelid, - ]; - } - else { - $defaultChannelId = TeamAliasForm::originalChannelId(); - $queryparam = [ - 'filter' => 'channelId=' . $defaultChannelId, - ]; - } - $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); - } - else { - $entities = $this->decorated()->getEntities($pager, $key_provider); + $queryparam = ($channelid) ? ['filter' => 'channelId=' . $channelid,] : ['filter' => 'channelId=' . $defaultChannelId,]; } } - else { - $entities = $this->decorated()->getEntities($pager, $key_provider); - } - + $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); return $entities; } From 40bcf4df817954b705357ec7d56c5cfbe112ad4f Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Thu, 12 Oct 2023 15:28:01 +0530 Subject: [PATCH 11/13] Minor changes requested --- .../src/Entity/Controller/TeamController.php | 6 ++++-- .../CachedPaginatedEntityListingControllerTrait.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php index 848c9e67..8b147912 100644 --- a/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php +++ b/modules/apigee_edge_teams/src/Entity/Controller/TeamController.php @@ -245,9 +245,11 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = $channelconfig = \Drupal::config('apigee_edge_teams.team_settings'); $channelid = $channelconfig->get('channelid'); $channelfilter = $channelconfig->get('enablefilter'); - $defaultChannelId = TeamAliasForm::originalChannelId(); if ($channelfilter) { - $queryparam = ($channelid) ? ['filter' => 'channelId=' . $channelid,] : ['filter' => 'channelId=' . $defaultChannelId,]; + $channelid = $channelid ? $channelid : TeamAliasForm::originalChannelId(); + $queryparam = [ + 'filter' => 'channelId=' . $channelid + ]; } } $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); diff --git a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php index 190d5194..d23233bc 100644 --- a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php +++ b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php @@ -45,7 +45,7 @@ abstract protected function decorated(); /** * {@inheritdoc} */ - public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id'): array { + public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id', $queryparam=[]): array { if ($this->entityCache()->isAllEntitiesInCache()) { if ($pager === NULL) { return $this->entityCache()->getEntities(); @@ -55,7 +55,7 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = } } - $entities = $this->decorated()->getEntities($pager, $key_provider); + $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); $this->entityCache()->saveEntities($entities); if ($pager === NULL) { $this->entityCache()->allEntitiesInCache(TRUE); From b1b58926ae67f63058a3e2defd8d1158211077ca Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Thu, 12 Oct 2023 15:46:14 +0530 Subject: [PATCH 12/13] PHPCBF fixes --- .../Controller/CachedPaginatedEntityListingControllerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php index d23233bc..a1962e3a 100644 --- a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php +++ b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php @@ -45,7 +45,7 @@ abstract protected function decorated(); /** * {@inheritdoc} */ - public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id', $queryparam=[]): array { + public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id', $queryparam = []): array { if ($this->entityCache()->isAllEntitiesInCache()) { if ($pager === NULL) { return $this->entityCache()->getEntities(); From 1036c9a6bea2a46fac7ddfea87415a21324e6862 Mon Sep 17 00:00:00 2001 From: Kedar Khaire Date: Fri, 13 Oct 2023 11:59:25 +0530 Subject: [PATCH 13/13] Removing unwanted changes --- .../CachedPaginatedEntityListingControllerTrait.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php index a1962e3a..190d5194 100644 --- a/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php +++ b/src/Entity/Controller/CachedPaginatedEntityListingControllerTrait.php @@ -45,7 +45,7 @@ abstract protected function decorated(); /** * {@inheritdoc} */ - public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id', $queryparam = []): array { + public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id'): array { if ($this->entityCache()->isAllEntitiesInCache()) { if ($pager === NULL) { return $this->entityCache()->getEntities(); @@ -55,7 +55,7 @@ public function getEntities(PagerInterface $pager = NULL, string $key_provider = } } - $entities = $this->decorated()->getEntities($pager, $key_provider, $queryparam); + $entities = $this->decorated()->getEntities($pager, $key_provider); $this->entityCache()->saveEntities($entities); if ($pager === NULL) { $this->entityCache()->allEntitiesInCache(TRUE);