Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/almanac/engineextension/AlmanacBindingsSearchEngineAttachment.php
12256 views
1
<?php
2
3
final class AlmanacBindingsSearchEngineAttachment
4
extends AlmanacSearchEngineAttachment {
5
6
private $isActive;
7
8
public function setIsActive($is_active) {
9
$this->isActive = $is_active;
10
return $this;
11
}
12
13
public function getIsActive() {
14
return $this->isActive;
15
}
16
17
public function getAttachmentName() {
18
return pht('Almanac Bindings');
19
}
20
21
public function getAttachmentDescription() {
22
return pht('Get Almanac bindings for the service.');
23
}
24
25
public function willLoadAttachmentData($query, $spec) {
26
$query->needProperties(true);
27
28
if ($this->getIsActive()) {
29
$query->needActiveBindings(true);
30
} else {
31
$query->needBindings(true);
32
}
33
}
34
35
public function getAttachmentForObject($object, $data, $spec) {
36
$bindings = array();
37
38
if ($this->getIsActive()) {
39
$service_bindings = $object->getActiveBindings();
40
} else {
41
$service_bindings = $object->getBindings();
42
}
43
44
foreach ($service_bindings as $binding) {
45
$bindings[] = $this->getAlmanacBindingDictionary($binding);
46
}
47
48
return array(
49
'bindings' => $bindings,
50
);
51
}
52
53
}
54
55