Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F573203
PhabricatorPolicyManagementShowWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorPolicyManagementShowWorkflow.php
View Options
<?php
final
class
PhabricatorPolicyManagementShowWorkflow
extends
PhabricatorPolicyManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'show'
)
->
setSynopsis
(
pht
(
'Show policy information about an object.'
))
->
setExamples
(
'**show** D123'
)
->
setArguments
(
array
(
array
(
'name'
=>
'objects'
,
'wildcard'
=>
true
,
),
));
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$console
=
PhutilConsole
::
getConsole
();
$viewer
=
$this
->
getViewer
();
$obj_names
=
$args
->
getArg
(
'objects'
);
if
(!
$obj_names
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify the name of an object to show policy information for.'
));
}
else
if
(
count
(
$obj_names
)
>
1
)
{
throw
new
PhutilArgumentUsageException
(
pht
(
'Specify the name of exactly one object to show policy information '
.
'for.'
));
}
$object
=
id
(
new
PhabricatorObjectQuery
())
->
setViewer
(
$viewer
)
->
withNames
(
$obj_names
)
->
executeOne
();
if
(!
$object
)
{
$name
=
head
(
$obj_names
);
throw
new
PhutilArgumentUsageException
(
pht
(
"No such object '%s'!"
,
$name
));
}
$handle
=
id
(
new
PhabricatorHandleQuery
())
->
setViewer
(
$viewer
)
->
withPHIDs
(
array
(
$object
->
getPHID
()))
->
executeOne
();
$policies
=
PhabricatorPolicyQuery
::
loadPolicies
(
$viewer
,
$object
);
$console
->
writeOut
(
"__%s__
\n\n
"
,
pht
(
'OBJECT'
));
$console
->
writeOut
(
" %s
\n
"
,
$handle
->
getFullName
());
$console
->
writeOut
(
"
\n
"
);
$console
->
writeOut
(
"__%s__
\n\n
"
,
pht
(
'CAPABILITIES'
));
foreach
(
$policies
as
$capability
=>
$policy
)
{
$ref
=
$policy
->
newRef
(
$viewer
);
$console
->
writeOut
(
" **%s**
\n
"
,
$capability
);
$console
->
writeOut
(
" %s
\n
"
,
$ref
->
getPolicyDisplayName
());
$console
->
writeOut
(
" %s
\n
"
,
PhabricatorPolicy
::
getPolicyExplanation
(
$viewer
,
$policy
->
getPHID
()));
$console
->
writeOut
(
"
\n
"
);
}
if
(
$object
instanceof
PhabricatorPolicyCodexInterface
)
{
$codex
=
PhabricatorPolicyCodex
::
newFromObject
(
$object
,
$viewer
);
$rules
=
$codex
->
getPolicySpecialRuleDescriptions
();
foreach
(
$rules
as
$rule
)
{
echo
tsprintf
(
" - %s
\n
"
,
$rule
->
getDescription
());
}
echo
"
\n
"
;
}
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, May 13, 5:45 PM (2 d)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
97218
Default Alt Text
PhabricatorPolicyManagementShowWorkflow.php (2 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment