@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 173 lines 4.9 kB view raw
1<?php 2 3final class DrydockBlueprintEditEngine 4 extends PhabricatorEditEngine { 5 6 private $blueprintImplementation; 7 8 const ENGINECONST = 'drydock.blueprint'; 9 10 public function isEngineConfigurable() { 11 return false; 12 } 13 14 public function getEngineName() { 15 return pht('Drydock Blueprints'); 16 } 17 18 public function getSummaryHeader() { 19 return pht('Edit Drydock Blueprint Configurations'); 20 } 21 22 public function getSummaryText() { 23 return pht('This engine is used to edit Drydock blueprints.'); 24 } 25 26 public function getEngineApplicationClass() { 27 return PhabricatorDrydockApplication::class; 28 } 29 30 public function setBlueprintImplementation( 31 DrydockBlueprintImplementation $impl) { 32 $this->blueprintImplementation = $impl; 33 return $this; 34 } 35 36 public function getBlueprintImplementation() { 37 return $this->blueprintImplementation; 38 } 39 40 protected function newEditableObject() { 41 $viewer = $this->getViewer(); 42 $blueprint = DrydockBlueprint::initializeNewBlueprint($viewer); 43 44 $impl = $this->getBlueprintImplementation(); 45 if ($impl) { 46 $blueprint 47 ->setClassName(get_class($impl)) 48 ->attachImplementation(clone $impl); 49 } 50 51 return $blueprint; 52 } 53 54 protected function newEditableObjectFromConduit(array $raw_xactions) { 55 $type = null; 56 foreach ($raw_xactions as $raw_xaction) { 57 if ($raw_xaction['type'] !== 'type') { 58 continue; 59 } 60 61 $type = $raw_xaction['value']; 62 } 63 64 if ($type === null) { 65 throw new Exception( 66 pht( 67 'When creating a new Drydock blueprint via the Conduit API, you '. 68 'must provide a "type" transaction to select a type.')); 69 } 70 71 $map = DrydockBlueprintImplementation::getAllBlueprintImplementations(); 72 if (!isset($map[$type])) { 73 throw new Exception( 74 pht( 75 'Blueprint type "%s" is unrecognized. Valid types are: %s.', 76 $type, 77 implode(', ', array_keys($map)))); 78 } 79 80 $impl = clone $map[$type]; 81 $this->setBlueprintImplementation($impl); 82 83 return $this->newEditableObject(); 84 } 85 86 protected function newEditableObjectForDocumentation() { 87 // In order to generate the proper list of fields/transactions for a 88 // blueprint, a blueprint's type needs to be known upfront, and there's 89 // currently no way to pre-specify the type. Hardcoding an implementation 90 // here prevents the fatal on the Conduit API page and allows transactions 91 // to be edited. 92 $impl = new DrydockWorkingCopyBlueprintImplementation(); 93 $this->setBlueprintImplementation($impl); 94 return $this->newEditableObject(); 95 } 96 97 protected function newObjectQuery() { 98 return new DrydockBlueprintQuery(); 99 } 100 101 protected function getObjectCreateTitleText($object) { 102 return pht('Create Blueprint'); 103 } 104 105 protected function getObjectCreateButtonText($object) { 106 return pht('Create Blueprint'); 107 } 108 109 protected function getObjectEditTitleText($object) { 110 return pht('Edit Blueprint: %s', $object->getBlueprintName()); 111 } 112 113 protected function getObjectEditShortText($object) { 114 return pht('Edit Blueprint'); 115 } 116 117 protected function getObjectCreateShortText() { 118 return pht('Create Blueprint'); 119 } 120 121 protected function getObjectName() { 122 return pht('Blueprint'); 123 } 124 125 protected function getEditorURI() { 126 return '/drydock/blueprint/edit/'; 127 } 128 129 protected function getObjectCreateCancelURI($object) { 130 return '/drydock/blueprint/'; 131 } 132 133 protected function getObjectViewURI($object) { 134 $id = $object->getID(); 135 return "/drydock/blueprint/{$id}/"; 136 } 137 138 protected function getCreateNewObjectPolicy() { 139 return $this->getApplication()->getPolicy( 140 DrydockCreateBlueprintsCapability::CAPABILITY); 141 } 142 143 protected function buildCustomEditFields($object) { 144 $impl = $object->getImplementation(); 145 146 return array( 147 // This field appears in the web UI 148 id(new PhabricatorStaticEditField()) 149 ->setKey('displayType') 150 ->setLabel(pht('Blueprint Type')) 151 ->setDescription(pht('Type of blueprint.')) 152 ->setValue($impl->getBlueprintName()), 153 id(new PhabricatorTextEditField()) 154 ->setKey('type') 155 ->setLabel(pht('Type')) 156 ->setIsFormField(false) 157 ->setTransactionType( 158 DrydockBlueprintTypeTransaction::TRANSACTIONTYPE) 159 ->setDescription(pht('When creating a blueprint, set the type.')) 160 ->setConduitDescription(pht('Set the blueprint type.')) 161 ->setConduitTypeDescription(pht('Blueprint type.')) 162 ->setValue($object->getClassName()), 163 id(new PhabricatorTextEditField()) 164 ->setKey('name') 165 ->setLabel(pht('Name')) 166 ->setDescription(pht('Name of the blueprint.')) 167 ->setTransactionType(DrydockBlueprintNameTransaction::TRANSACTIONTYPE) 168 ->setIsRequired(true) 169 ->setValue($object->getBlueprintName()), 170 ); 171 } 172 173}