Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / harbormaster / artifact / HarbormasterFileArtifact.php
blob91fc025c21ef3118421a9fe23023065a1dd4789e
1 <?php
3 final class HarbormasterFileArtifact extends HarbormasterArtifact {
5 const ARTIFACTCONST = 'file';
7 public function getArtifactTypeName() {
8 return pht('File');
11 public function getArtifactTypeDescription() {
12 return pht(
13 'Stores a reference to file data which has been uploaded to '.
14 'Phabricator.');
17 public function getArtifactParameterSpecification() {
18 return array(
19 'filePHID' => 'string',
23 public function getArtifactParameterDescriptions() {
24 return array(
25 'filePHID' => pht('File to create an artifact from.'),
29 public function getArtifactDataExample() {
30 return array(
31 'filePHID' => 'PHID-FILE-abcdefghijklmnopqrst',
35 public function renderArtifactSummary(PhabricatorUser $viewer) {
36 $artifact = $this->getBuildArtifact();
37 $file_phid = $artifact->getProperty('filePHID');
38 return $viewer->renderHandle($file_phid);
41 public function willCreateArtifact(PhabricatorUser $actor) {
42 // NOTE: This is primarily making sure the actor has permission to view the
43 // file. We don't want to let you run builds using files you don't have
44 // permission to see, since this could let you violate permissions.
45 $this->loadArtifactFile($actor);
48 public function loadArtifactFile(PhabricatorUser $viewer) {
49 $artifact = $this->getBuildArtifact();
50 $file_phid = $artifact->getProperty('filePHID');
52 $file = id(new PhabricatorFileQuery())
53 ->setViewer($viewer)
54 ->withPHIDs(array($file_phid))
55 ->executeOne();
56 if (!$file) {
57 throw new Exception(
58 pht(
59 'File PHID "%s" does not correspond to a valid file.',
60 $file_phid));
63 return $file;