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 Jun 30, 2020
1 parent b44314d commit 4e796fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"guzzlehttp/guzzle": "^5.3",
"guzzlehttp/ringphp": "^1.1",
"platformsh/console-form": ">=0.0.24 <2.0",
"platformsh/client": ">=0.33.0 <2.0",
"platformsh/client": ">=0.34.0 <2.0",
"symfony/console": "^3.0 >=3.2",
"symfony/yaml": "^3.0 || ^2.6",
"symfony/finder": "^3.0",
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 @@ -310,7 +301,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 4e796fb

Please sign in to comment.