Skip to content

Commit 3f7558d

Browse files
committed
Add support for SelectableOption input.
1 parent 8b7f803 commit 3f7558d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace ProcessWire\GraphQL\Type\Enum;
4+
5+
use Youshido\GraphQL\Type\Enum\AbstractEnumType;
6+
use ProcessWire\Field;
7+
8+
class SelectableOptionEnumType extends AbstractEnumType {
9+
10+
function __construct(Field $field)
11+
{
12+
$this->field = $field;
13+
parent::__construct([]);
14+
}
15+
16+
public function getValues()
17+
{
18+
$options = [];
19+
foreach ($this->field->type->getOptions($this->field) as $option) {
20+
$options[] = [
21+
'value' => $option->id,
22+
'name' => $option->value | $option->title,
23+
];
24+
}
25+
return $options;
26+
}
27+
28+
}

0 commit comments

Comments
 (0)