Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/customfield/DifferentialAsanaRepresentationField.php
12256 views
1
<?php
2
3
final class DifferentialAsanaRepresentationField
4
extends DifferentialCustomField {
5
6
public function getFieldKey() {
7
return 'differential:asana-representation';
8
}
9
10
public function getFieldName() {
11
return pht('In Asana');
12
}
13
14
public function canDisableField() {
15
return false;
16
}
17
18
public function getFieldDescription() {
19
return pht('Shows revision representation in Asana.');
20
}
21
22
public function shouldAppearInPropertyView() {
23
return (bool)PhabricatorEnv::getEnvConfig('asana.workspace-id');
24
}
25
26
public function renderPropertyViewLabel() {
27
return $this->getFieldName();
28
}
29
30
public function renderPropertyViewValue(array $handles) {
31
$viewer = $this->getViewer();
32
$src_phid = $this->getObject()->getPHID();
33
$edge_type = PhabricatorObjectHasAsanaTaskEdgeType::EDGECONST;
34
35
$query = id(new PhabricatorEdgeQuery())
36
->withSourcePHIDs(array($src_phid))
37
->withEdgeTypes(array($edge_type))
38
->needEdgeData(true);
39
40
$edges = $query->execute();
41
if (!$edges) {
42
return null;
43
}
44
45
$edge = head($edges[$src_phid][$edge_type]);
46
47
if (!$edge) {
48
return null;
49
}
50
51
if (!empty($edge['data']['gone'])) {
52
return phutil_tag(
53
'em',
54
array(),
55
pht('Asana Task Deleted'));
56
}
57
58
$ref = id(new DoorkeeperImportEngine())
59
->setViewer($viewer)
60
->withPHIDs(array($edge['dst']))
61
->needLocalOnly(true)
62
->executeOne();
63
64
if (!$ref) {
65
return null;
66
}
67
68
return id(new DoorkeeperTagView())
69
->setExternalObject($ref->getExternalObject());
70
}
71
72
}
73
74