-
Notifications
You must be signed in to change notification settings - Fork 61
/
DBFloatArgs.php
44 lines (36 loc) · 1.03 KB
/
DBFloatArgs.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace SilverStripe\GraphQL\Schema\DataObject\Plugin\DBFieldArgs;
use SilverStripe\GraphQL\Schema\Field\ModelField;
use SilverStripe\GraphQL\Schema\Type\Enum;
class DBFloatArgs extends DBFieldArgs
{
public function getEnum(): Enum
{
return Enum::create(
'DBFloatFormattingOptions',
$this->getValues(),
'Formatting options for fields that map to DBFloat data types'
);
}
public function applyToField(ModelField $field): void
{
$field->addArg('format', [
'type' => $this->getEnum()->getName(),
'description' => 'Formatting options for this field',
])->addResolverAfterware(
$this->getResolver()
);
}
protected function getResolver(): callable
{
return [DBFieldArgs::class, 'baseFormatResolver'];
}
public function getValues(): array
{
return [
'NICE' => 'Nice',
'ROUND' => 'Round',
'NICE_ROUND' => 'NiceRound',
];
}
}