This repository has been archived by the owner on May 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbootstrap.php
79 lines (64 loc) · 1.95 KB
/
bootstrap.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
<?php
/**
* @file
* Implements bootstrap commands.
*/
// CLI includes.
if (COCKPIT_CLI) {
$this->path('#cli', __DIR__ . '/cli');
}
// Incldude admin.
if (COCKPIT_ADMIN && !COCKPIT_API_REQUEST) {
$this->module('helpers')->extend([
'getQuickActions' => function() {
$config = $this->app->config['helpers'];
return $config['quickactions'] ?? [];
},
'getCollectionEntries' => function($type, $limit = 25) {
$options = [
'populate' => 0,
'limit' => $limit,
];
$entries = $this->app->module('collections')->find($type, $options);
return $entries ?? [];
},
'getSingletons' => function($group = NULL, $limit = 25) {
$results = $this->app->module('singletons')->singletons();
$singletons = [];
foreach ($results as $singleton) {
if ($singleton['group'] === $group) {
$singletons[] = [
'label' => $singleton['label'],
'value' => $singleton['name'],
];
}
}
return $singletons;
},
'removeMaxRevisions' => function($type, $name, $_id) {
$settings = $this->app->config['helpers'] ?? [];
$maxRevisions = $settings['maxRevisions'] ?? FALSE;
$maxRev = 0;
if (!empty($maxRevisions[$name])) {
$maxRev = (int) $maxRevisions[$name];
}
elseif (!empty($maxRevisions[$type])) {
$maxRev = (int) $maxRevisions[$type];
}
$revisions = $this->app->helper('revisions')->getList($_id);
if ($maxRev > 1 && count($revisions) > $maxRev) {
$revisions = array_slice($revisions, $maxRev, count($revisions) - 1);
foreach ($revisions as $revision) {
$this->app->helper('revisions')->remove($revision['_id']);
}
}
}
]);
include_once __DIR__ . '/admin.php';
include_once __DIR__ . '/actions.php';
}
// Incldude admin.
if (COCKPIT_API_REQUEST) {
include_once __DIR__ . '/actions.php';
include_once __DIR__ . '/api.php';
}