Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/storage/DrydockCommand.php
12256 views
1
<?php
2
3
final class DrydockCommand
4
extends DrydockDAO
5
implements PhabricatorPolicyInterface {
6
7
const COMMAND_RELEASE = 'release';
8
const COMMAND_RECLAIM = 'reclaim';
9
10
protected $authorPHID;
11
protected $targetPHID;
12
protected $command;
13
protected $isConsumed;
14
protected $properties = array();
15
16
private $commandTarget = self::ATTACHABLE;
17
18
public static function initializeNewCommand(PhabricatorUser $author) {
19
return id(new DrydockCommand())
20
->setAuthorPHID($author->getPHID())
21
->setIsConsumed(0);
22
}
23
24
protected function getConfiguration() {
25
return array(
26
self::CONFIG_SERIALIZATION => array(
27
'properties' => self::SERIALIZATION_JSON,
28
),
29
self::CONFIG_COLUMN_SCHEMA => array(
30
'command' => 'text32',
31
'isConsumed' => 'bool',
32
),
33
self::CONFIG_KEY_SCHEMA => array(
34
'key_target' => array(
35
'columns' => array('targetPHID', 'isConsumed'),
36
),
37
),
38
) + parent::getConfiguration();
39
}
40
41
public function attachCommandTarget($target) {
42
$this->commandTarget = $target;
43
return $this;
44
}
45
46
public function getCommandTarget() {
47
return $this->assertAttached($this->commandTarget);
48
}
49
50
public function setProperty($key, $value) {
51
$this->properties[$key] = $value;
52
return $this;
53
}
54
55
public function getProperty($key, $default = null) {
56
return idx($this->properties, $key, $default);
57
}
58
59
/* -( PhabricatorPolicyInterface )----------------------------------------- */
60
61
62
public function getCapabilities() {
63
return array(
64
PhabricatorPolicyCapability::CAN_VIEW,
65
);
66
}
67
68
public function getPolicy($capability) {
69
return $this->getCommandTarget()->getPolicy($capability);
70
}
71
72
public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
73
return $this->getCommandTarget()->hasAutomaticCapability(
74
$capability,
75
$viewer);
76
}
77
78
public function describeAutomaticCapability($capability) {
79
return pht('Drydock commands have the same policies as their targets.');
80
}
81
82
}
83
84