-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGraphQLFieldtypePageTable.module
More file actions
executable file
·73 lines (65 loc) · 1.74 KB
/
GraphQLFieldtypePageTable.module
File metadata and controls
executable file
·73 lines (65 loc) · 1.74 KB
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
<?php
/**
* COPYRIGHT NOTICE
* Copyright (c) 2025 Neue Rituale GbR
* @author NR <code@neuerituale.com>
* @license MIT
*/
namespace ProcessWire;
use GraphQL\Type\Definition\ObjectType;
use GraphQL\Type\Definition\Type;
use ProcessWire\GraphQL\Type\PageArrayType;
class GraphQLFieldtypePageTable extends WireData implements Module
{
public static function getModuleInfo() {
return array(
'title' => 'GraphQLFieldtypePageTable',
'version' => 205,
'summary' => 'GraphQL support for FieldtypePageTable.',
'icon' => 'globe',
'requires' => ['ProcessGraphQL'],
'installs' => ['ProcessGraphQL']
);
}
public static function getType(Field $field) {
require_once "ContentElementType.php";
return new ObjectType([
'name' => 'PageTable',
'fields' => array_merge(PageArrayType::getPaginationFields(), [
[
'name' => 'list',
'type' => Type::listOf(ContentElementType::type()),
'description' => 'List of Content Elements',
'resolve' => function ($value) {
return $value;
},
],
[
'name' => 'first',
'type' => ContentElementType::type(),
'description' => 'Returns the first item in the PageTableArray.',
'resolve' => function ($value) {
$first = $value->first();
return $first ?: null;
},
],
[
'name' => 'last',
'type' => ContentElementType::type(),
'description' => 'Returns the last item in the PageTableArray.',
'resolve' => function ($value) {
$last = $value->last();
return $last ?: null;
},
]
]),
]);
}
public static function getInputType(Field $field) {
return Type::string();
}
public static function setValue(Page $page, Field $field, $value) {
$fieldName = $field->name;
$page->$fieldName = $value;
}
}