-
Notifications
You must be signed in to change notification settings - Fork 1
/
GraphQLFieldtypeOembed.module
executable file
·119 lines (95 loc) · 2.79 KB
/
GraphQLFieldtypeOembed.module
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/**
* COPYRIGHT NOTICE
* Copyright (c) 2023 Neue Rituale GbR
* @author NR <code@neuerituale.com>
*/
namespace ProcessWire;
use GraphQL\Type\Definition\Type;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\InputObjectType;
class GraphQLFieldtypeOembed extends WireData implements Module {
/**
* getModuleInfo is a module required by all modules to tell ProcessWire about them
* @return array
*/
public static function getModuleInfo() {
return [
'title' => 'GraphQLFieldtypeOembed',
'version' => 116,
'summary' => 'GraphQL support for FieldtypeOembed.',
'icon' => 'globe',
'requires' => ['FieldtypeOembed']
];
}
public static function getType(Field $field) {
return new ObjectType([
'name' => 'Oembed',
'fields' => [
'empty' => [
'type' => Type::boolean(),
'resolve' => function($value) { return (boolean) $value->empty; }
],
'title' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->title; }
],
'authorName' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->authorName; }
],
'authorUrl' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->authorUrl; }
],
'type' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->type; }
],
'height' => [
'type' => Type::int(),
'resolve' => function($value) { return (int) $value->height; }
],
'width' => [
'type' => Type::int(),
'resolve' => function($value) { return (int) $value->width; }
],
'providerName' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->providerName; }
],
'providerUrl' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->providerUrl; }
],
'thumbnailHeight' => [
'type' => Type::int(),
'resolve' => function($value) { return (int) $value->thumbnailHeight; }
],
'thumbnailWidth' => [
'type' => Type::int(),
'resolve' => function($value) { return (int) $value->thumbnailWidth; }
],
'thumbnailUrl' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->thumbnailUrl; }
],
'html' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->html; }
],
'url' => [
'type' => Type::string(),
'resolve' => function($value) { return (string) $value->url; }
],
],
]);
}
public static function getInputType(Field $field) {
return Type::string();
}
public static function setValue(Page $page, Field $field, $value) {
$fieldName = $field->name;
$page->$fieldName = $value;
}
}