Remove product literal strings in "pht()", part 6
[phabricator.git] / src / applications / policy / view / PhabricatorPolicyRef.php
blob605d59ee4542423e59d2b088792f8e04ddfc37db
1 <?php
3 final class PhabricatorPolicyRef
4 extends Phobject {
6 private $viewer;
7 private $policy;
9 public function setViewer(PhabricatorUser $viewer) {
10 $this->viewer = $viewer;
11 return $this;
14 public function getViewer() {
15 return $this->viewer;
18 public function setPolicy(PhabricatorPolicy $policy) {
19 $this->policy = $policy;
20 return $this;
23 public function getPolicy() {
24 return $this->policy;
27 public function getPolicyDisplayName() {
28 $policy = $this->getPolicy();
29 return $policy->getFullName();
32 public function newTransactionLink(
33 $mode,
34 PhabricatorApplicationTransaction $xaction) {
36 $policy = $this->getPolicy();
38 if ($policy->isCustomPolicy()) {
39 $uri = urisprintf(
40 '/transactions/%s/%s/',
41 $mode,
42 $xaction->getPHID());
43 $workflow = true;
44 } else {
45 $uri = $policy->getHref();
46 $workflow = false;
49 return $this->newLink($uri, $workflow);
52 public function newCapabilityLink($object, $capability) {
53 $policy = $this->getPolicy();
55 $uri = urisprintf(
56 '/policy/explain/%s/%s/',
57 $object->getPHID(),
58 $capability);
60 return $this->newLink($uri, true);
63 private function newLink($uri, $workflow) {
64 $policy = $this->getPolicy();
65 $name = $policy->getName();
67 if ($uri !== null) {
68 $name = javelin_tag(
69 'a',
70 array(
71 'href' => $uri,
72 'sigil' => ($workflow ? 'workflow' : null),
74 $name);
77 $hint = $this->getPolicyTypeHint();
78 if ($hint !== null) {
79 $name = pht('%s (%s)', $name, $hint);
82 return $name;
85 private function getPolicyTypeHint() {
86 $policy = $this->getPolicy();
88 if ($policy->isProjectPolicy()) {
89 return pht('Project');
92 if ($policy->isMaskedPolicy()) {
93 return pht('You do not have permission to view policy details.');
96 return null;