[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class PholioImage extends PholioDAO 4 implements 5 PhabricatorMarkupInterface, 6 PhabricatorPolicyInterface { 7 8 const MARKUP_FIELD_DESCRIPTION = 'markup:description'; 9 10 protected $mockID; 11 protected $filePHID; 12 protected $name = ''; 13 protected $description = ''; 14 protected $sequence; 15 protected $isObsolete = 0; 16 protected $replacesImagePHID = null; 17 18 private $inlineComments = self::ATTACHABLE; 19 private $file = self::ATTACHABLE; 20 private $mock = self::ATTACHABLE; 21 22 public function getConfiguration() { 23 return array( 24 self::CONFIG_AUX_PHID => true, 25 self::CONFIG_COLUMN_SCHEMA => array( 26 'mockID' => 'id?', 27 'name' => 'text128', 28 'description' => 'text', 29 'sequence' => 'uint32', 30 'isObsolete' => 'bool', 31 'replacesImagePHID' => 'phid?', 32 ), 33 self::CONFIG_KEY_SCHEMA => array( 34 'key_phid' => null, 35 'keyPHID' => array( 36 'columns' => array('phid'), 37 'unique' => true, 38 ), 39 'mockID' => array( 40 'columns' => array('mockID', 'isObsolete', 'sequence'), 41 ), 42 ), 43 ) + parent::getConfiguration(); 44 } 45 46 public function generatePHID() { 47 return PhabricatorPHID::generateNewPHID(PholioImagePHIDType::TYPECONST); 48 } 49 50 public function attachFile(PhabricatorFile $file) { 51 $this->file = $file; 52 return $this; 53 } 54 55 public function getFile() { 56 $this->assertAttached($this->file); 57 return $this->file; 58 } 59 60 public function attachMock(PholioMock $mock) { 61 $this->mock = $mock; 62 return $this; 63 } 64 65 public function getMock() { 66 $this->assertAttached($this->mock); 67 return $this->mock; 68 } 69 70 71 public function attachInlineComments(array $inline_comments) { 72 assert_instances_of($inline_comments, 'PholioTransactionComment'); 73 $this->inlineComments = $inline_comments; 74 return $this; 75 } 76 77 public function getInlineComments() { 78 $this->assertAttached($this->inlineComments); 79 return $this->inlineComments; 80 } 81 82 83 /* -( PhabricatorMarkupInterface )----------------------------------------- */ 84 85 86 public function getMarkupFieldKey($field) { 87 $hash = PhabricatorHash::digest($this->getMarkupText($field)); 88 return 'M:'.$hash; 89 } 90 91 public function newMarkupEngine($field) { 92 return PhabricatorMarkupEngine::newMarkupEngine(array()); 93 } 94 95 public function getMarkupText($field) { 96 return $this->getDescription(); 97 } 98 99 public function didMarkupText($field, $output, PhutilMarkupEngine $engine) { 100 return $output; 101 } 102 103 public function shouldUseMarkupCache($field) { 104 return (bool)$this->getID(); 105 } 106 107 /* -( PhabricatorPolicyInterface Implementation )-------------------------- */ 108 109 public function getCapabilities() { 110 return $this->getMock()->getCapabilities(); 111 } 112 113 public function getPolicy($capability) { 114 return $this->getMock()->getPolicy($capability); 115 } 116 117 // really the *mock* controls who can see an image 118 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) { 119 return $this->getMock()->hasAutomaticCapability($capability, $viewer); 120 } 121 122 public function describeAutomaticCapability($capability) { 123 return null; 124 } 125 126 }
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 |