GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ProcessGraphQL/src/Utils.php at master · gioqw/ProcessGraphQL

Expand file tree

/

Utils.php

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
245 lines (212 loc) · 5.63 KB
/

Utils.php

Copy path

File metadata and controls

245 lines (212 loc) · 5.63 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
<?php
/**
* Serves the same purpose as ProcessWire's Functions.php
* This one here is in case we need to overwrite some functions
* or add some more
*/
namespace ProcessWire\GraphQL;
use ProcessWire\Field;
use ProcessWire\Template;
class Utils {
/**
* Same as ProcessWire wire function.
* @param string $name The name of the api. E.g. `pages`, `modules`, `templates`.
* @return mixed Returns the ProcessWire API variable.
*/
public static function wire($name='wire')
{
return \ProcessWire\wire($name);
}
/**
* Shorcut for wire('pages')
* @return \ProcessWire\Pages The ProcessWire $pages API variable.
*/
public static function pages()
{
return self::wire('pages');
}
/**
* Shortcut for wire('user')
* @return \ProcessWire\User The ProcessWire $user API variable.
*/
public static function user()
{
return self::wire('user');
}
/**
* Shortcut for wire('users')
* @return \ProcessWire\Users The ProcessWire $users variable.
*/
public static function users()
{
return self::wire('users');
}
/**
* Shortcut for wire('modules')
* @return \ProcessWire\Modules The ProcessWire $modules API variable
*/
public static function modules()
{
return self::wire('modules');
}
/**
* Shortcut for wire('templates')
* @return \ProcessWire\Templates The ProcessWire $templates API variable.
*/
public static function templates()
{
return self::wire('templates');
}
/**
* Shortcut for wire('fields')
* @return \ProcessWire\Fields The ProcessWire $fields API variable.
*/
public static function fields()
{
return self::wire('fields');
}
/**
* Shortcut for wire('sanitizer')
* @return \ProcessWire\Sanitizer The ProcessWire $sanitizer variable.
*/
public static function sanitizer()
{
return self::wire('sanitizer');
}
/**
* Shortcut for wire('config')
* @return \ProcessWire\Config The ProcessWire $config API variable.
*/
public static function config()
{
return self::wire('config');
}
/**
* Shortcut for wire('session')
* @return \ProcessWire\Session The ProcessWire $session variable.
*/
public static function session()
{
return self::wire('session');
}
/**
* Shortcut for wire('users')
* @return \ProcessWire\Users The ProcessWire $users variabe.
*/
public static function roles()
{
return self::wire('roles');
}
/**
* Shortcut for wire('permissions')
* @return \ProcessWire\Permissions The ProcessWire $permissions variable.
*/
public static function permissions()
{
return self::wire('permissions');
}
/**
* Returns the ProcessGraphQL module instance.
* @return \ProcessWire\ProcessGraphQL The ProcessGraphQL module instance
*/
public static function module()
{
return self::modules()->get('ProcessGraphQL');
}
/**
* Shortcut for wire('languages')
* @return ProcessWire\Languages The ProcessWire $languages API variable.
*/
public static function languages()
{
return self::wire('languages');
}
/**
* Shortcut for wire('database')
* @return ProcessWire\Database The ProcessWire $database API variable.
*/
public static function database()
{
return self::wire('database');
}
/**
* An array of reserved words for future use
* @return array Array of strings.
*/
public static function getReservedWords()
{
return [
'me', 'debug', 'login', 'logout',
'pages','templates','template','fields',
'roles', 'permissions', 'config', 'system',
'wire', 'enum', 'trash', 'users', 'setup',
'modules', 'access', 'find', 'logs', 'site',
'core',
];
}
/**
* Matches a ProcessWire Fieldtype to corresponding GraphQL Field
* @param Field $field A Processwire field.
* @return mixed|null Returns a GraphQL compatible field or null if match is not found.
*/
public static function pwFieldToGraphqlClass(Field $field)
{
// use local field if available
$className = "\\ProcessWire\\GraphQL\\Type\\Fieldtype\\" . $field->type->className();
if (class_exists($className)) {
return $className;
}
// use third party field if available
$thirdPartyFieldtypeClassName = "ProcessWire\\GraphQL\\Type\\Fieldtype\\FieldtypeThirdParty";
if (class_exists($thirdPartyFieldtypeClassName::getThirdPartyClassName($field))) {
return $thirdPartyFieldtypeClassName;
}
return null;
}
/**
* Used for circular dependant types. Until the type is built in full this
* placeholder is used. See Cache::type() for an example.
*/
public static function placeholder()
{
return 'placeholder';
}
public static function normalizeFieldName($name)
{
return Utils::sanitizer()->camelCase($name);
}
public static function normalizeTypeName($name)
{
return ucfirst(Utils::normalizeFieldName($name));
}
/**
* Checks if the template is a repeater template
* @param Template $template
* @return boolean True if the template is repeater template, false otherwise.
*/
public static function isRepeaterTemplate(Template $template)
{
// if it's not prefixed with "repeater_" then it's not a repeater template
if (strpos($template->name, 'repeater_') !== 0) {
return false;
}
// if it's not flagged as system then it's not repeater
if (!($template->flags & Template::flagSystem)) {
return false;
}
return true;
}
}
function log($data, $label = '')
{
echo "\n======================================\n";
if ($label) {
echo "$label\n";
}
echo $data;
echo "\n======================================\n";
}
function logArr($data, $label = '')
{
log(json_encode($data, JSON_PRETTY_PRINT), $label);
}
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.