Skip to content

Commit

Permalink
Use the setup API to fetch the plans list in the project:create (crea…
Browse files Browse the repository at this point in the history
…te) command
  • Loading branch information
pjcdawkins committed Jul 21, 2020
1 parent 071539e commit 47d3c72
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/Command/Project/ProjectCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,16 +243,7 @@ protected function getAvailablePlans($runtime = false)
return (array) $this->config()->get('service.available_plans');
}

$plans = [];
foreach ($this->api()->getClient()->getPlans() as $plan) {
if ($plan->hasProperty('price', false)) {
$plans[$plan->name] = sprintf('%s (%s)', $plan->label, $plan->price->__toString());
} else {
$plans[$plan->name] = $plan->label;
}
}

return $plans;
return $plans = $this->api()->getClient()->getSetupOptions()->plans;
}

/**
Expand Down Expand Up @@ -311,7 +302,11 @@ protected function getFields()
'optionsCallback' => function () {
return $this->getAvailablePlans(true);
},
'default' => in_array('development', $this->getAvailablePlans()) ? 'development' : null,
// @todo ensure the default is based on the dynamic list and works during resolveOptions()
//'default' => 'development',
'defaultCallback' => function() {
return in_array('development', $this->getAvailablePlans(true)) ? 'development' : null;
},
'allowOther' => true,
]),
'environments' => new Field('Environments', [
Expand Down

0 comments on commit 47d3c72

Please sign in to comment.