Skip to content
Snippets Groups Projects

Issue #3278824: Passing in multiple types into a parameter breaks frontend controllers

2 files
+ 11
7
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -138,7 +138,7 @@ class HttpConfigRequestForm extends EntityForm {
continue;
}
$type = $param->getType();
$type = is_array($param->getType()) ? array_values($param->getType())[0] : $param->getType();
switch ($type) {
case 'bool':
case 'boolean':
@@ -272,7 +272,7 @@ class HttpConfigRequestForm extends EntityForm {
/** @var \GuzzleHttp\Command\Guzzle\Parameter $param */
$param = $element['#command_param'];
$type = $param->getType();
$type = is_array($param->getType()) ? array_values($param->getType())[0] : $param->getType();
switch ($type) {
case 'array':
@@ -322,7 +322,8 @@ class HttpConfigRequestForm extends EntityForm {
/** @var \GuzzleHttp\Command\Guzzle\Parameter $param */
$param = $element['#command_param'];
$assoc = $param->getType() == 'array' ? JSON_OBJECT_AS_ARRAY : JSON_FORCE_OBJECT;
$type = is_array($param->getType()) ? array_values($param->getType())[0] : $param->getType();
$assoc = $type == 'array' ? JSON_OBJECT_AS_ARRAY : JSON_FORCE_OBJECT;
$item = json_decode($input, $assoc);
if (json_last_error() !== JSON_ERROR_NONE) {
@@ -357,7 +358,8 @@ class HttpConfigRequestForm extends EntityForm {
* A JSON String.
*/
protected function getJsonHelp(Parameter $param) {
if ($param->getType() == 'array') {
$type = is_array($param->getType()) ? array_values($param->getType())[0] : $param->getType();
if ($type == 'array') {
$properties = $param->getItems()->getProperties();
}
else {
@@ -366,7 +368,8 @@ class HttpConfigRequestForm extends EntityForm {
$array = [];
foreach ($properties as $name => $parameter) {
switch ($parameter->getType()) {
$parameter_type = is_array($parameter->getType()) ? array_values($parameter->getType())[0] : $parameter->getType();
switch ($parameter_type) {
case 'string':
$sample = 'Lorem ipsum...';
break;
@@ -400,7 +403,7 @@ class HttpConfigRequestForm extends EntityForm {
$array[$name] = $sample;
}
if ($param->getType() == 'array') {
if ($type == 'array') {
$array = [$array];
}
return json_encode($array, JSON_PRETTY_PRINT);
Loading