Path: blob/master/src/applications/drydock/storage/DrydockCommand.php
12256 views
<?php12final class DrydockCommand3extends DrydockDAO4implements PhabricatorPolicyInterface {56const COMMAND_RELEASE = 'release';7const COMMAND_RECLAIM = 'reclaim';89protected $authorPHID;10protected $targetPHID;11protected $command;12protected $isConsumed;13protected $properties = array();1415private $commandTarget = self::ATTACHABLE;1617public static function initializeNewCommand(PhabricatorUser $author) {18return id(new DrydockCommand())19->setAuthorPHID($author->getPHID())20->setIsConsumed(0);21}2223protected function getConfiguration() {24return array(25self::CONFIG_SERIALIZATION => array(26'properties' => self::SERIALIZATION_JSON,27),28self::CONFIG_COLUMN_SCHEMA => array(29'command' => 'text32',30'isConsumed' => 'bool',31),32self::CONFIG_KEY_SCHEMA => array(33'key_target' => array(34'columns' => array('targetPHID', 'isConsumed'),35),36),37) + parent::getConfiguration();38}3940public function attachCommandTarget($target) {41$this->commandTarget = $target;42return $this;43}4445public function getCommandTarget() {46return $this->assertAttached($this->commandTarget);47}4849public function setProperty($key, $value) {50$this->properties[$key] = $value;51return $this;52}5354public function getProperty($key, $default = null) {55return idx($this->properties, $key, $default);56}5758/* -( PhabricatorPolicyInterface )----------------------------------------- */596061public function getCapabilities() {62return array(63PhabricatorPolicyCapability::CAN_VIEW,64);65}6667public function getPolicy($capability) {68return $this->getCommandTarget()->getPolicy($capability);69}7071public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {72return $this->getCommandTarget()->hasAutomaticCapability(73$capability,74$viewer);75}7677public function describeAutomaticCapability($capability) {78return pht('Drydock commands have the same policies as their targets.');79}8081}828384