Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/nuance/storage/NuanceItemCommand.php
12256 views
1
<?php
2
3
final class NuanceItemCommand
4
extends NuanceDAO
5
implements PhabricatorPolicyInterface {
6
7
const STATUS_ISSUED = 'issued';
8
const STATUS_EXECUTING = 'executing';
9
const STATUS_DONE = 'done';
10
const STATUS_FAILED = 'failed';
11
12
protected $itemPHID;
13
protected $authorPHID;
14
protected $queuePHID;
15
protected $command;
16
protected $status;
17
protected $parameters = array();
18
19
public static function initializeNewCommand() {
20
return id(new self())
21
->setStatus(self::STATUS_ISSUED);
22
}
23
24
protected function getConfiguration() {
25
return array(
26
self::CONFIG_SERIALIZATION => array(
27
'parameters' => self::SERIALIZATION_JSON,
28
),
29
self::CONFIG_COLUMN_SCHEMA => array(
30
'command' => 'text64',
31
'status' => 'text64',
32
'queuePHID' => 'phid?',
33
),
34
self::CONFIG_KEY_SCHEMA => array(
35
'key_pending' => array(
36
'columns' => array('itemPHID', 'status'),
37
),
38
),
39
) + parent::getConfiguration();
40
}
41
42
public static function getStatusMap() {
43
return array(
44
self::STATUS_ISSUED => array(
45
'name' => pht('Issued'),
46
'icon' => 'fa-clock-o',
47
'color' => 'bluegrey',
48
),
49
self::STATUS_EXECUTING => array(
50
'name' => pht('Executing'),
51
'icon' => 'fa-play',
52
'color' => 'green',
53
),
54
self::STATUS_DONE => array(
55
'name' => pht('Done'),
56
'icon' => 'fa-check',
57
'color' => 'blue',
58
),
59
self::STATUS_FAILED => array(
60
'name' => pht('Failed'),
61
'icon' => 'fa-times',
62
'color' => 'red',
63
),
64
);
65
}
66
67
private function getStatusSpec() {
68
$map = self::getStatusMap();
69
return idx($map, $this->getStatus(), array());
70
}
71
72
public function getStatusIcon() {
73
$spec = $this->getStatusSpec();
74
return idx($spec, 'icon', 'fa-question');
75
}
76
77
public function getStatusColor() {
78
$spec = $this->getStatusSpec();
79
return idx($spec, 'color', 'indigo');
80
}
81
82
public function getStatusName() {
83
$spec = $this->getStatusSpec();
84
return idx($spec, 'name', $this->getStatus());
85
}
86
87
88
/* -( PhabricatorPolicyInterface )----------------------------------------- */
89
90
91
public function getCapabilities() {
92
return array(
93
PhabricatorPolicyCapability::CAN_VIEW,
94
);
95
}
96
97
public function getPolicy($capability) {
98
return PhabricatorPolicies::getMostOpenPolicy();
99
}
100
101
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
102
return false;
103
}
104
105
}
106
107