-
Notifications
You must be signed in to change notification settings - Fork 15
/
LinkTypeResolver.php
41 lines (35 loc) · 1.28 KB
/
LinkTypeResolver.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
<?php
namespace SilverStripe\LinkField\GraphQL;
use GraphQL\Type\Definition\ResolveInfo;
use InvalidArgumentException;
use SilverStripe\GraphQL\Schema\DataObject\Resolver;
use SilverStripe\LinkField\Type\Registry;
use SilverStripe\LinkField\Type\Type;
use SilverStripe\Dev\Deprecation;
/**
* @deprecated 3.0.0 Will be removed without equivalent functionality to replace it
*/
class LinkTypeResolver extends Resolver
{
public function __construct()
{
Deprecation::withNoReplacement(function () {
Deprecation::notice('3.0.0', 'Will be removed without equivalent functionality to replace it', Deprecation::SCOPE_CLASS);
});
}
public static function resolve($obj, $args = [], $context = [], ?ResolveInfo $info = null)
{
if (isset($args['keys']) && !is_array($args['keys'])) {
throw new InvalidArgumentException('If `keys` is provdied, it must be an array');
}
$types = Registry::singleton()->list();
$flattenType = array_map(function (Type $type, string $key) {
return [
'key' => $key,
'handlerName' => $type->LinkTypeHandlerName(),
'title' => $type->LinkTypeTile()
];
}, $types, array_keys($types));
return $flattenType;
}
}