Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F807056
PhabricatorPolicyRef.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
PhabricatorPolicyRef.php
View Options
<?php
final
class
PhabricatorPolicyRef
extends
Phobject
{
private
$viewer
;
private
$policy
;
public
function
setViewer
(
PhabricatorUser
$viewer
)
{
$this
->
viewer
=
$viewer
;
return
$this
;
}
public
function
getViewer
()
{
return
$this
->
viewer
;
}
public
function
setPolicy
(
PhabricatorPolicy
$policy
)
{
$this
->
policy
=
$policy
;
return
$this
;
}
public
function
getPolicy
()
{
return
$this
->
policy
;
}
public
function
getPolicyDisplayName
()
{
$policy
=
$this
->
getPolicy
();
return
$policy
->
getFullName
();
}
public
function
newTransactionLink
(
$mode
,
PhabricatorApplicationTransaction
$xaction
)
{
$policy
=
$this
->
getPolicy
();
if
(
$policy
->
isCustomPolicy
())
{
$uri
=
urisprintf
(
'/transactions/%s/%s/'
,
$mode
,
$xaction
->
getPHID
());
$workflow
=
true
;
}
else
{
$uri
=
$policy
->
getHref
();
$workflow
=
false
;
}
return
$this
->
newLink
(
$uri
,
$workflow
);
}
public
function
newCapabilityLink
(
$object
,
$capability
)
{
$policy
=
$this
->
getPolicy
();
$uri
=
urisprintf
(
'/policy/explain/%s/%s/'
,
$object
->
getPHID
(),
$capability
);
return
$this
->
newLink
(
$uri
,
true
);
}
private
function
newLink
(
$uri
,
$workflow
)
{
$policy
=
$this
->
getPolicy
();
$name
=
$policy
->
getName
();
if
(
$uri
!==
null
)
{
$name
=
javelin_tag
(
'a'
,
array
(
'href'
=>
$uri
,
'sigil'
=>
(
$workflow
?
'workflow'
:
null
),
),
$name
);
}
$hint
=
$this
->
getPolicyTypeHint
();
if
(
$hint
!==
null
)
{
$name
=
pht
(
'%s (%s)'
,
$name
,
$hint
);
}
return
$name
;
}
private
function
getPolicyTypeHint
()
{
$policy
=
$this
->
getPolicy
();
if
(
$policy
->
isProjectPolicy
())
{
return
pht
(
'Project'
);
}
if
(
$policy
->
isMaskedPolicy
())
{
return
pht
(
'You do not have permission to view policy details.'
);
}
return
null
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Thu, May 29, 1:36 PM (21 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
169922
Default Alt Text
PhabricatorPolicyRef.php (1 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment