|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link http://www.newicon.net/neon |
|
4
|
|
|
* @copyright Copyright (c) 2019 Newicon Ltd |
|
5
|
|
|
* @license http://www.newicon.net/neon/license/ |
|
6
|
|
|
* @author Steve O'Brien <[email protected]> |
|
7
|
|
|
* @package neon |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace neon\daedalus\controllers\api; |
|
11
|
|
|
|
|
12
|
|
|
use neon\core\web\ApiController; |
|
13
|
|
|
use yii\web\HttpException; |
|
14
|
|
|
|
|
15
|
|
|
class MapController extends ApiController |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @inheritdoc |
|
19
|
|
|
*/ |
|
20
|
|
|
public function verbs() |
|
21
|
|
|
{ |
|
22
|
|
|
return [ |
|
23
|
|
|
'classes' => ['get'], |
|
24
|
|
|
'objects' => ['get'] |
|
25
|
|
|
]; |
|
26
|
|
|
} |
|
27
|
|
|
/** |
|
28
|
|
|
* Get the set of classes that have a map field defined |
|
29
|
|
|
*/ |
|
30
|
|
|
public function actionClasses() |
|
31
|
|
|
{ |
|
32
|
|
|
return neon('dds')->getDataMapTypes(); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Get the map of uuid to object map field with optional filtering on |
|
38
|
|
|
* an additional field e.g a linking field with a uuid. |
|
39
|
|
|
* |
|
40
|
|
|
* @param string $class the class_type of the object you want the map on |
|
41
|
|
|
* @param string $filter a filter on the map field which will be used in |
|
42
|
|
|
* a like comparison |
|
43
|
|
|
* @param integer $length the number of items you want returned (defaults to 100) |
|
44
|
|
|
* @param string $member an additional member that you want to filter on |
|
45
|
|
|
* @param string $value the value for that member |
|
46
|
|
|
* @param integer $start where to start from in the list (defaults to beginning) |
|
47
|
|
|
* @return array uuid => map field |
|
48
|
|
|
* @throws |
|
49
|
|
|
*/ |
|
50
|
|
|
public function actionObjects($class, $filter='', $length=100, $member='', $value='', $start=0) |
|
51
|
|
|
{ |
|
52
|
|
|
$mapFilter = []; |
|
53
|
|
|
if (!$class) |
|
54
|
|
|
throw new HttpException(404, "No class name provided"); |
|
55
|
|
|
if ($member && $value) |
|
56
|
|
|
$mapFilter[$member]=$value; |
|
57
|
|
|
if ($filter && is_string($filter)) |
|
58
|
|
|
$mapFilter['_map_field_']=$filter; |
|
59
|
|
|
return neon()->getDds()->IDdsObjectManagement->getObjectMap($class, $mapFilter, [], $start, $length); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function actionUserTypes() |
|
63
|
|
|
{ |
|
64
|
|
|
return neon('user')->getDataMapTypes(); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function actionUsers($filter='') |
|
68
|
|
|
{ |
|
69
|
|
|
return neon('user')->getDataMap('users', $filter); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function actionPages($filter='') |
|
73
|
|
|
{ |
|
74
|
|
|
return neon('cms')->getDataMap('pages', $filter); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function actionPhoebe($type='', $filter='') |
|
78
|
|
|
{ |
|
79
|
|
|
$filters = []; |
|
80
|
|
|
if (!$filter) { |
|
81
|
|
|
if ($type === 'phoebe_class') { |
|
82
|
|
|
$filters = ['or', |
|
83
|
|
|
['like', 'label', $filter], |
|
84
|
|
|
['like', 'class_type', $filter] |
|
85
|
|
|
]; |
|
86
|
|
|
} |
|
87
|
|
|
else if ($type === 'phoebe_object') { |
|
88
|
|
|
$filters = ['like', 'uuid', $filter]; |
|
89
|
|
|
} |
|
90
|
|
|
} |
|
91
|
|
|
return neon('phoebe')->getDataMap($type, $filters); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|