3 final class PhabricatorPolicyManagementShowWorkflow
4 extends PhabricatorPolicyManagementWorkflow
{
6 protected function didConstruct() {
9 ->setSynopsis(pht('Show policy information about an object.'))
10 ->setExamples('**show** D123')
20 public function execute(PhutilArgumentParser
$args) {
21 $console = PhutilConsole
::getConsole();
22 $viewer = $this->getViewer();
24 $obj_names = $args->getArg('objects');
26 throw new PhutilArgumentUsageException(
27 pht('Specify the name of an object to show policy information for.'));
28 } else if (count($obj_names) > 1) {
29 throw new PhutilArgumentUsageException(
31 'Specify the name of exactly one object to show policy information '.
35 $object = id(new PhabricatorObjectQuery())
37 ->withNames($obj_names)
41 $name = head($obj_names);
42 throw new PhutilArgumentUsageException(
44 "No such object '%s'!",
48 $handle = id(new PhabricatorHandleQuery())
50 ->withPHIDs(array($object->getPHID()))
53 $policies = PhabricatorPolicyQuery
::loadPolicies(
57 $console->writeOut("__%s__\n\n", pht('OBJECT'));
58 $console->writeOut(" %s\n", $handle->getFullName());
59 $console->writeOut("\n");
61 $console->writeOut("__%s__\n\n", pht('CAPABILITIES'));
62 foreach ($policies as $capability => $policy) {
63 $ref = $policy->newRef($viewer);
65 $console->writeOut(" **%s**\n", $capability);
66 $console->writeOut(" %s\n", $ref->getPolicyDisplayName());
67 $console->writeOut(" %s\n",
68 PhabricatorPolicy
::getPolicyExplanation($viewer, $policy->getPHID()));
69 $console->writeOut("\n");
72 if ($object instanceof PhabricatorPolicyCodexInterface
) {
73 $codex = PhabricatorPolicyCodex
::newFromObject($object, $viewer);
75 $rules = $codex->getPolicySpecialRuleDescriptions();
76 foreach ($rules as $rule) {
79 $rule->getDescription());