Skip to content

Commit 4e796fb

Browse files
committed
Use the setup API to fetch the plans list in the project:create (create) command
1 parent b44314d commit 4e796fb

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"guzzlehttp/guzzle": "^5.3",
99
"guzzlehttp/ringphp": "^1.1",
1010
"platformsh/console-form": ">=0.0.24 <2.0",
11-
"platformsh/client": ">=0.33.0 <2.0",
11+
"platformsh/client": ">=0.34.0 <2.0",
1212
"symfony/console": "^3.0 >=3.2",
1313
"symfony/yaml": "^3.0 || ^2.6",
1414
"symfony/finder": "^3.0",

composer.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Command/Project/ProjectCreateCommand.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,7 @@ protected function getAvailablePlans($runtime = false)
243243
return (array) $this->config()->get('service.available_plans');
244244
}
245245

246-
$plans = [];
247-
foreach ($this->api()->getClient()->getPlans() as $plan) {
248-
if ($plan->hasProperty('price', false)) {
249-
$plans[$plan->name] = sprintf('%s (%s)', $plan->label, $plan->price->__toString());
250-
} else {
251-
$plans[$plan->name] = $plan->label;
252-
}
253-
}
254-
255-
return $plans;
246+
return $plans = $this->api()->getClient()->getSetupOptions()->plans;
256247
}
257248

258249
/**
@@ -310,7 +301,11 @@ protected function getFields()
310301
'optionsCallback' => function () {
311302
return $this->getAvailablePlans(true);
312303
},
313-
'default' => in_array('development', $this->getAvailablePlans()) ? 'development' : null,
304+
// @todo ensure the default is based on the dynamic list and works during resolveOptions()
305+
//'default' => 'development',
306+
'defaultCallback' => function() {
307+
return in_array('development', $this->getAvailablePlans(true)) ? 'development' : null;
308+
},
314309
'allowOther' => true,
315310
]),
316311
'environments' => new Field('Environments', [

0 commit comments

Comments
 (0)