From 47d3c729ee3304d7a7a9aacf5ee440ba57bb1ec8 Mon Sep 17 00:00:00 2001 From: Patrick Dawkins Date: Tue, 30 Jun 2020 14:19:00 +0100 Subject: [PATCH] Use the setup API to fetch the plans list in the project:create (create) command --- src/Command/Project/ProjectCreateCommand.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Command/Project/ProjectCreateCommand.php b/src/Command/Project/ProjectCreateCommand.php index 7d860d2af..88dd62ae2 100644 --- a/src/Command/Project/ProjectCreateCommand.php +++ b/src/Command/Project/ProjectCreateCommand.php @@ -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; } /** @@ -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', [