Skip to content

Commit 47d3c72

Browse files
committed
Use the setup API to fetch the plans list in the project:create (create) command
1 parent 071539e commit 47d3c72

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

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
/**
@@ -311,7 +302,11 @@ protected function getFields()
311302
'optionsCallback' => function () {
312303
return $this->getAvailablePlans(true);
313304
},
314-
'default' => in_array('development', $this->getAvailablePlans()) ? 'development' : null,
305+
// @todo ensure the default is based on the dynamic list and works during resolveOptions()
306+
//'default' => 'development',
307+
'defaultCallback' => function() {
308+
return in_array('development', $this->getAvailablePlans(true)) ? 'development' : null;
309+
},
315310
'allowOther' => true,
316311
]),
317312
'environments' => new Field('Environments', [

0 commit comments

Comments
 (0)