Skip to content

Commit

Permalink
Merge pull request #860 from PhMemmel/patch-2
Browse files Browse the repository at this point in the history
Fix missing description parameters in external_value constructor all
  • Loading branch information
andrewnicols authored Jan 15, 2024
2 parents 9e16af1 + 716a743 commit 6af6a07
Showing 1 changed file with 33 additions and 7 deletions.
40 changes: 33 additions & 7 deletions docs/apis/subsystems/external/writing-a-service.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,23 @@ Because some web service protocols are strict about the number and types of argu
```php
public static function get_biscuit_parameters() {
return new external_function_parameters([
'chocolatechips' => new external_value(PARAM_BOOL, PARAM_REQUIRED),
'glutenfree' => new external_value(PARAM_BOOL, PARAM_DEFAULT, false),
'chocolatechips' => new external_value(
PARAM_BOOL,
'if biscuit contains chocolate chips',
VALUE_REQUIRED
),
'glutenfree' => new external_value(
type: PARAM_BOOL,
required: VALUE_DEFAULT,
default: false,
allownull: false
),
// ERROR! top level optional parameter!!!
'icingsugar' => new external_value(PARAM_BOOL, VALUE_OPTIONAL),
'icingsugar' => new external_value(
PARAM_BOOL,
'if biscuit has icing sugar on top',
VALUE_OPTIONAL
),
]);
}
```
Expand All @@ -332,10 +345,23 @@ public static function get_biscuit_parameters() {
public static function get_biscuit_parameters() {
return new external_function_parameters([
'ifeellike' => new external_single_structure([
'chocolatechips' => new external_value(PARAM_BOOL, VALUE_REQUIRED),
'glutenfree' => new external_value(PARAM_BOOL, PARAM_DEFAULT, false),
// ALL GOOD!! We have nested the params in a external_single_structure.
'icingsugar' => new external_value(PARAM_BOOL, VALUE_OPTIONAL),
'chocolatechips' => new external_value(
PARAM_BOOL,
'if biscuit contains chocolate chips',
VALUE_REQUIRED
),
'glutenfree' => new external_value(
type: PARAM_BOOL,
required: VALUE_DEFAULT,
default: false,
allownull: false
),
// ALL GOOD!! We have nested the params in an external_single_structure.
'icingsugar' => new external_value(
PARAM_BOOL,
'if biscuit has icing sugar on top',
VALUE_OPTIONAL
),
]),
]);
}
Expand Down

0 comments on commit 6af6a07

Please sign in to comment.