Skip to content

Commit 2934c5a

Browse files
authored
App creation fails without API Products (#809)
* App creation fails without API Products caused by features.keymanagement.disable.unbounded.permissions flag * Update minimum version of apigee-client-php
1 parent 9cd5270 commit 2934c5a

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

.github/workflows/php.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,17 @@ jobs:
6363
id: composercache
6464
run: |
6565
cd drupal
66-
echo "::set-output name=dir::$(composer config cache-files-dir)"
66+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
6767
6868
- name: Cache composer dependencies
69-
uses: actions/cache@v2
69+
uses: actions/cache@v3
7070
with:
7171
path: ${{ steps.composercache.outputs.dir }}
7272
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
7373
restore-keys: ${{ runner.os }}-composer-
7474

7575
- name: Checkout apigee_edge module
76-
uses: actions/checkout@v3.0.0
76+
uses: actions/checkout@v3
7777
with:
7878
path: drupal/modules/contrib/apigee_edge
7979

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"require": {
77
"php": "^7.4 || ^8.0",
88
"ext-json": "*",
9-
"apigee/apigee-client-php": "^2.0.16",
9+
"apigee/apigee-client-php": "^2.0.19",
1010
"drupal/core": "^9.4",
1111
"drupal/entity": "^1.0",
1212
"drupal/key": "^1.8",

src/Entity/App.php

+7
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,11 @@ public static function uniqueIdProperties(): array {
458458
return array_merge(parent::uniqueIdProperties(), ['appId']);
459459
}
460460

461+
/**
462+
* {@inheritdoc}
463+
*/
464+
public function setInitialApiProducts(array $initialApiProducts): void {
465+
$this->decorated->setInitialApiProducts($initialApiProducts);
466+
}
467+
461468
}

src/Entity/Form/AppForm.php

+13
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public function buildEntity(array $form, FormStateInterface $form_state) {
124124
// Set the owner of the app. Without this an app can not be saved.
125125
// @see \Drupal\apigee_edge\Entity\Controller\DeveloperAppEdgeEntityControllerProxy::create()
126126
$entity->setAppOwner($form_state->getValue('owner'));
127+
128+
// Set the api_products while creating App initially.
129+
if ($form_state->getValue('api_products')) {
130+
if (is_array($form_state->getValue('api_products'))) {
131+
// API Products are multiselect.
132+
$entity->setInitialApiProducts(array_keys(array_filter($form_state->getValue('api_products'))));
133+
}
134+
else {
135+
// API Products are single select or radio.
136+
$entity->setInitialApiProducts([$form_state->getValue('api_products')]);
137+
}
138+
}
139+
127140
return $entity;
128141
}
129142

tests/src/Functional/DeveloperAppUITestTrait.php

+1
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,7 @@ protected function assertAppCreationWithProduct(array $products = [], bool $mult
296296
'name' => $name,
297297
'displayName[0][value]' => $name,
298298
];
299+
299300
if (count($products) === 1) {
300301
$formdata['api_products'] = reset($products)->getName();
301302
}

0 commit comments

Comments
 (0)