[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PhabricatorPolicyManagementShowWorkflow 4 extends PhabricatorPolicyManagementWorkflow { 5 6 protected function didConstruct() { 7 $this 8 ->setName('show') 9 ->setSynopsis('Show policy information about an object.') 10 ->setExamples( 11 '**show** D123') 12 ->setArguments( 13 array( 14 array( 15 'name' => 'objects', 16 'wildcard' => true, 17 ), 18 )); 19 } 20 21 public function execute(PhutilArgumentParser $args) { 22 $console = PhutilConsole::getConsole(); 23 $viewer = $this->getViewer(); 24 25 $obj_names = $args->getArg('objects'); 26 if (!$obj_names) { 27 throw new PhutilArgumentUsageException( 28 pht( 29 'Specify the name of an object to show policy information for.')); 30 } else if (count($obj_names) > 1) { 31 throw new PhutilArgumentUsageException( 32 pht( 33 'Specify the name of exactly one object to show policy information '. 34 'for.')); 35 } 36 37 $object = id(new PhabricatorObjectQuery()) 38 ->setViewer($viewer) 39 ->withNames($obj_names) 40 ->executeOne(); 41 42 if (!$object) { 43 $name = head($obj_names); 44 throw new PhutilArgumentUsageException( 45 pht( 46 "No such object '%s'!", 47 $name)); 48 } 49 50 $handle = id(new PhabricatorHandleQuery()) 51 ->setViewer($viewer) 52 ->withPHIDs(array($object->getPHID())) 53 ->executeOne(); 54 55 $policies = PhabricatorPolicyQuery::loadPolicies( 56 $viewer, 57 $object); 58 59 $console->writeOut("__%s__\n\n", pht('OBJECT')); 60 $console->writeOut(" %s\n", $handle->getFullName()); 61 $console->writeOut("\n"); 62 63 $console->writeOut("__%s__\n\n", pht('CAPABILITIES')); 64 foreach ($policies as $capability => $policy) { 65 $console->writeOut(" **%s**\n", $capability); 66 $console->writeOut(" %s\n", $policy->renderDescription()); 67 $console->writeOut(" %s\n", 68 PhabricatorPolicy::getPolicyExplanation($viewer, $policy->getPHID())); 69 $console->writeOut("\n"); 70 71 $more = (array)$object->describeAutomaticCapability($capability); 72 if ($more) { 73 foreach ($more as $line) { 74 $console->writeOut(" %s\n", $line); 75 } 76 $console->writeOut("\n"); 77 } 78 } 79 80 } 81 82 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |