Skip to content

Commit

Permalink
App creation fails without API Products (#809)
Browse files Browse the repository at this point in the history
* App creation fails without API Products caused by features.keymanagement.disable.unbounded.permissions flag
* Update minimum version of apigee-client-php
  • Loading branch information
phdhiren authored Mar 16, 2023
1 parent 9cd5270 commit 2934c5a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,17 @@ jobs:
id: composercache
run: |
cd drupal
echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Checkout apigee_edge module
uses: actions/checkout@v3.0.0
uses: actions/checkout@v3
with:
path: drupal/modules/contrib/apigee_edge

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"require": {
"php": "^7.4 || ^8.0",
"ext-json": "*",
"apigee/apigee-client-php": "^2.0.16",
"apigee/apigee-client-php": "^2.0.19",
"drupal/core": "^9.4",
"drupal/entity": "^1.0",
"drupal/key": "^1.8",
Expand Down
7 changes: 7 additions & 0 deletions src/Entity/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,4 +458,11 @@ public static function uniqueIdProperties(): array {
return array_merge(parent::uniqueIdProperties(), ['appId']);
}

/**
* {@inheritdoc}
*/
public function setInitialApiProducts(array $initialApiProducts): void {
$this->decorated->setInitialApiProducts($initialApiProducts);
}

}
13 changes: 13 additions & 0 deletions src/Entity/Form/AppForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
// Set the owner of the app. Without this an app can not be saved.
// @see \Drupal\apigee_edge\Entity\Controller\DeveloperAppEdgeEntityControllerProxy::create()
$entity->setAppOwner($form_state->getValue('owner'));

// Set the api_products while creating App initially.
if ($form_state->getValue('api_products')) {
if (is_array($form_state->getValue('api_products'))) {
// API Products are multiselect.
$entity->setInitialApiProducts(array_keys(array_filter($form_state->getValue('api_products'))));
}
else {
// API Products are single select or radio.
$entity->setInitialApiProducts([$form_state->getValue('api_products')]);
}
}

return $entity;
}

Expand Down
1 change: 1 addition & 0 deletions tests/src/Functional/DeveloperAppUITestTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ protected function assertAppCreationWithProduct(array $products = [], bool $mult
'name' => $name,
'displayName[0][value]' => $name,
];

if (count($products) === 1) {
$formdata['api_products'] = reset($products)->getName();
}
Expand Down

0 comments on commit 2934c5a

Please sign in to comment.