-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathModules.php
More file actions
49 lines (39 loc) · 1.28 KB
/
Modules.php
File metadata and controls
49 lines (39 loc) · 1.28 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
<?php
namespace StartupAPI\API\v1;
/**
* @package StartupAPI
* @subpackage API
*/
require_once(dirname(__DIR__) . '/Endpoint.php');
/**
* Returns modules available in the system
*
* @package StartupAPI
* @subpackage API
*/
class Modules extends \StartupAPI\API\Endpoint {
public function __construct() {
parent::__construct('/v1/modules', 'Returns a list of modules configured in the system');
}
public function call($values, $raw_request_body = null) {
$results = [];
foreach (\UserConfig::$all_modules as $module) {
$result = [
'id' => $module->getID(),
'title' => $module->getTitle()
];
if (is_subclass_of($module, '\AuthenticationModule', false)) {
$result['type'] = 'authentication';
$result['is_compact'] = $module->isCompact();
} else if (is_subclass_of($module, '\PaymentEngine', false)) {
$result['type'] = 'payment';
} else if (is_subclass_of($module, '\EmailModule', false)) {
$result['type'] = 'email';
} else if (is_subclass_of($module, '\StartupAPIModule', false)) {
$result['type'] = 'other';
}
$results[] = $result;
}
return $results;
}
}