-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjsonapi.extension.php
98 lines (92 loc) · 1.97 KB
/
jsonapi.extension.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
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
<?php
require_once(__DIR__ . '/JsonApiController.php');
if (c::get('jsonapi.built-in.enabled', false))
{
$auth = c::get('jsonapi.built-in.auth', null);
if ($auth === false)
{
$auth = null;
}
else if ($auth)
{
// invoke the auth configuration provider
$auth = $auth();
}
else
{
$auth = Lar\JsonApi\JsonApiAuth::isAdmin();
}
$lang = c::get('jsonapi.built-in.lang', null);
if (is_callable($lang))
{
$lang = $lang();
}
else if ($lang !== false)
{
$lang = Lar\JsonApi\JsonApiLang::fromQuery();
}
jsonapi()->register([
// api/page/_id_
[
'auth' => $auth,
'lang' => $lang,
'method' => 'GET',
'pattern' => "page/(:all)",
'controller' => 'Lar\JsonApi\JsonApiController',
'action' => 'getPage',
],
// api/child-ids/_id_
[
'auth' => $auth,
'lang' => $lang,
'method' => 'GET',
'pattern' => "child-ids/(:all)",
'controller' => 'Lar\JsonApi\JsonApiController',
'action' => 'getChildIds',
],
// api/children/_id_
[
'auth' => $auth,
'lang' => $lang,
'method' => 'GET',
'pattern' => "children/(:all)",
'controller' => 'Lar\JsonApi\JsonApiController',
'action' => 'getChildren',
],
// api/files/_id_
[
'auth' => $auth,
'lang' => $lang,
'method' => 'GET',
'pattern' => "files/(:all)",
'controller' => 'Lar\JsonApi\JsonApiController',
'action' => 'getFiles',
],
// api/node/_id_
[
'auth' => $auth,
'lang' => $lang,
'method' => 'GET',
'pattern' => "node/(:all)",
'controller' => 'Lar\JsonApi\JsonApiController',
'action' => 'getNode',
],
// api/tree/_id_
[
'auth' => $auth,
'lang' => $lang,
'method' => 'GET',
'pattern' => "tree/(:all)",
'controller' => 'Lar\JsonApi\JsonApiController',
'action' => 'getTree',
],
// // api/filter/_id_?filter=_filter-expr_
// [
// 'auth' => $auth,
// 'method' => 'GET',
// 'pattern' => "filter/(:all)",
// 'controller' => 'Lar\JsonApi\JsonApiController',
// 'action' => 'getFilteredChildren',
// ],
]);
}