Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/harbormaster/artifact/HarbormasterFileArtifact.php
12256 views
1
<?php
2
3
final class HarbormasterFileArtifact extends HarbormasterArtifact {
4
5
const ARTIFACTCONST = 'file';
6
7
public function getArtifactTypeName() {
8
return pht('File');
9
}
10
11
public function getArtifactTypeDescription() {
12
return pht(
13
'Stores a reference to file data.');
14
}
15
16
public function getArtifactParameterSpecification() {
17
return array(
18
'filePHID' => 'string',
19
);
20
}
21
22
public function getArtifactParameterDescriptions() {
23
return array(
24
'filePHID' => pht('File to create an artifact from.'),
25
);
26
}
27
28
public function getArtifactDataExample() {
29
return array(
30
'filePHID' => 'PHID-FILE-abcdefghijklmnopqrst',
31
);
32
}
33
34
public function renderArtifactSummary(PhabricatorUser $viewer) {
35
$artifact = $this->getBuildArtifact();
36
$file_phid = $artifact->getProperty('filePHID');
37
return $viewer->renderHandle($file_phid);
38
}
39
40
public function willCreateArtifact(PhabricatorUser $actor) {
41
// NOTE: This is primarily making sure the actor has permission to view the
42
// file. We don't want to let you run builds using files you don't have
43
// permission to see, since this could let you violate permissions.
44
$this->loadArtifactFile($actor);
45
}
46
47
public function loadArtifactFile(PhabricatorUser $viewer) {
48
$artifact = $this->getBuildArtifact();
49
$file_phid = $artifact->getProperty('filePHID');
50
51
$file = id(new PhabricatorFileQuery())
52
->setViewer($viewer)
53
->withPHIDs(array($file_phid))
54
->executeOne();
55
if (!$file) {
56
throw new Exception(
57
pht(
58
'File PHID "%s" does not correspond to a valid file.',
59
$file_phid));
60
}
61
62
return $file;
63
}
64
65
}
66
67