Remove product literal strings in "pht()", part 19
[phabricator.git] / src / applications / harbormaster / artifact / HarbormasterFileArtifact.php
blob6b536d8efa0168e5caf4da949dd83a88a63a09bd
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.');
16 public function getArtifactParameterSpecification() {
17 return array(
18 'filePHID' => 'string',
22 public function getArtifactParameterDescriptions() {
23 return array(
24 'filePHID' => pht('File to create an artifact from.'),
28 public function getArtifactDataExample() {
29 return array(
30 'filePHID' => 'PHID-FILE-abcdefghijklmnopqrst',
34 public function renderArtifactSummary(PhabricatorUser $viewer) {
35 $artifact = $this->getBuildArtifact();
36 $file_phid = $artifact->getProperty('filePHID');
37 return $viewer->renderHandle($file_phid);
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);
47 public function loadArtifactFile(PhabricatorUser $viewer) {
48 $artifact = $this->getBuildArtifact();
49 $file_phid = $artifact->getProperty('filePHID');
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));
62 return $file;