@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.

Improve Conduit type handling for `*.edit` endpoints

Summary:
Ref T9964. Three goals here:

- Make it easier to supply Conduit documentation.
- Make automatic documentation for `*.edit` endpoints more complete, particularly for custom fields.
- Allow type resolution via Conduit types, so you can pass `["alincoln"]` to "subscribers" instead of needing to use PHIDs.

Test Plan:
- Viewed and used all search and edit endpoints, including custom fields.
- Used parameter type resolution to set subscribers to user "dog" instead of "PHID-USER-whatever".
- Viewed HTTP parameter documentation.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9964

Differential Revision: https://secure.phabricator.com/D14796

+510 -191
+4
src/__phutil_library_map__.php
··· 238 238 'ConduitMethodDoesNotExistException' => 'applications/conduit/protocol/exception/ConduitMethodDoesNotExistException.php', 239 239 'ConduitMethodNotFoundException' => 'applications/conduit/protocol/exception/ConduitMethodNotFoundException.php', 240 240 'ConduitPHIDListParameterType' => 'applications/conduit/parametertype/ConduitPHIDListParameterType.php', 241 + 'ConduitPHIDParameterType' => 'applications/conduit/parametertype/ConduitPHIDParameterType.php', 241 242 'ConduitParameterType' => 'applications/conduit/parametertype/ConduitParameterType.php', 242 243 'ConduitPingConduitAPIMethod' => 'applications/conduit/method/ConduitPingConduitAPIMethod.php', 243 244 'ConduitProjectListParameterType' => 'applications/conduit/parametertype/ConduitProjectListParameterType.php', ··· 248 249 'ConduitStringParameterType' => 'applications/conduit/parametertype/ConduitStringParameterType.php', 249 250 'ConduitTokenGarbageCollector' => 'applications/conduit/garbagecollector/ConduitTokenGarbageCollector.php', 250 251 'ConduitUserListParameterType' => 'applications/conduit/parametertype/ConduitUserListParameterType.php', 252 + 'ConduitWildParameterType' => 'applications/conduit/parametertype/ConduitWildParameterType.php', 251 253 'ConpherenceColumnViewController' => 'applications/conpherence/controller/ConpherenceColumnViewController.php', 252 254 'ConpherenceConduitAPIMethod' => 'applications/conpherence/conduit/ConpherenceConduitAPIMethod.php', 253 255 'ConpherenceConfigOptions' => 'applications/conpherence/config/ConpherenceConfigOptions.php', ··· 4103 4105 'ConduitMethodDoesNotExistException' => 'ConduitMethodNotFoundException', 4104 4106 'ConduitMethodNotFoundException' => 'ConduitException', 4105 4107 'ConduitPHIDListParameterType' => 'ConduitListParameterType', 4108 + 'ConduitPHIDParameterType' => 'ConduitListParameterType', 4106 4109 'ConduitParameterType' => 'Phobject', 4107 4110 'ConduitPingConduitAPIMethod' => 'ConduitAPIMethod', 4108 4111 'ConduitProjectListParameterType' => 'ConduitListParameterType', ··· 4113 4116 'ConduitStringParameterType' => 'ConduitListParameterType', 4114 4117 'ConduitTokenGarbageCollector' => 'PhabricatorGarbageCollector', 4115 4118 'ConduitUserListParameterType' => 'ConduitListParameterType', 4119 + 'ConduitWildParameterType' => 'ConduitListParameterType', 4116 4120 'ConpherenceColumnViewController' => 'ConpherenceController', 4117 4121 'ConpherenceConduitAPIMethod' => 'ConduitAPIMethod', 4118 4122 'ConpherenceConfigOptions' => 'PhabricatorApplicationConfigOptions',
+35
src/applications/conduit/parametertype/ConduitPHIDParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitPHIDParameterType 4 + extends ConduitListParameterType { 5 + 6 + protected function getParameterValue(array $request, $key) { 7 + $value = parent::getParameterValue($request, $key); 8 + 9 + if (!is_string($value)) { 10 + $this->raiseValidationException( 11 + $request, 12 + $key, 13 + pht('Expected PHID, got something else.')); 14 + } 15 + 16 + return $value; 17 + } 18 + 19 + protected function getParameterTypeName() { 20 + return 'phid'; 21 + } 22 + 23 + protected function getParameterFormatDescriptions() { 24 + return array( 25 + pht('A PHID.'), 26 + ); 27 + } 28 + 29 + protected function getParameterExamples() { 30 + return array( 31 + '"PHID-WXYZ-1111222233334444"', 32 + ); 33 + } 34 + 35 + }
+22
src/applications/conduit/parametertype/ConduitWildParameterType.php
··· 1 + <?php 2 + 3 + final class ConduitWildParameterType 4 + extends ConduitListParameterType { 5 + 6 + protected function getParameterTypeName() { 7 + return 'wild'; 8 + } 9 + 10 + protected function getParameterFormatDescriptions() { 11 + return array( 12 + pht('Any mixed or complex value. Check the documentation for details.'), 13 + ); 14 + } 15 + 16 + protected function getParameterExamples() { 17 + return array( 18 + pht('(Wildcard)'), 19 + ); 20 + } 21 + 22 + }
+15
src/applications/maniphest/editor/ManiphestEditEngine.php
··· 76 76 ->setKey('parent') 77 77 ->setLabel(pht('Parent Task')) 78 78 ->setDescription(pht('Task to make this a subtask of.')) 79 + ->setConduitDescription(pht('Create as a subtask of another task.')) 80 + ->setConduitTypeDescription(pht('PHID of the parent task.')) 79 81 ->setAliases(array('parentPHID')) 80 82 ->setTransactionType(ManiphestTransaction::TYPE_PARENT) 81 83 ->setHandleParameterType(new ManiphestTaskListHTTPParameterType()) ··· 87 89 ->setKey('column') 88 90 ->setLabel(pht('Column')) 89 91 ->setDescription(pht('Workboard column to create this task into.')) 92 + ->setConduitDescription(pht('Create into a workboard column.')) 93 + ->setConduitTypeDescription(pht('PHID of workboard column.')) 90 94 ->setAliases(array('columnPHID')) 91 95 ->setTransactionType(ManiphestTransaction::TYPE_COLUMN) 92 96 ->setSingleValue(null) ··· 98 102 ->setKey('title') 99 103 ->setLabel(pht('Title')) 100 104 ->setDescription(pht('Name of the task.')) 105 + ->setConduitDescription(pht('Rename the task.')) 106 + ->setConduitTypeDescription(pht('New task name.')) 101 107 ->setTransactionType(ManiphestTransaction::TYPE_TITLE) 102 108 ->setIsRequired(true) 103 109 ->setValue($object->getTitle()), ··· 106 112 ->setAliases(array('ownerPHID', 'assign', 'assigned')) 107 113 ->setLabel(pht('Assigned To')) 108 114 ->setDescription(pht('User who is responsible for the task.')) 115 + ->setConduitDescription(pht('Reassign the task.')) 116 + ->setConduitTypeDescription( 117 + pht('New task owner, or `null` to unassign.')) 109 118 ->setTransactionType(ManiphestTransaction::TYPE_OWNER) 110 119 ->setIsCopyable(true) 111 120 ->setSingleValue($object->getOwnerPHID()) ··· 115 124 ->setKey('status') 116 125 ->setLabel(pht('Status')) 117 126 ->setDescription(pht('Status of the task.')) 127 + ->setConduitDescription(pht('Change the task status.')) 128 + ->setConduitTypeDescription(pht('New task status constant.')) 118 129 ->setTransactionType(ManiphestTransaction::TYPE_STATUS) 119 130 ->setIsCopyable(true) 120 131 ->setValue($object->getStatus()) ··· 125 136 ->setKey('priority') 126 137 ->setLabel(pht('Priority')) 127 138 ->setDescription(pht('Priority of the task.')) 139 + ->setConduitDescription(pht('Change the priority of the task.')) 140 + ->setConduitTypeDescription(pht('New task priority constant.')) 128 141 ->setTransactionType(ManiphestTransaction::TYPE_PRIORITY) 129 142 ->setIsCopyable(true) 130 143 ->setValue($object->getPriority()) ··· 134 147 ->setKey('description') 135 148 ->setLabel(pht('Description')) 136 149 ->setDescription(pht('Task description.')) 150 + ->setConduitDescription(pht('Update the task description.')) 151 + ->setConduitTypeDescription(pht('New task description.')) 137 152 ->setTransactionType(ManiphestTransaction::TYPE_DESCRIPTION) 138 153 ->setValue($object->getDescription()), 139 154 );
+4 -1
src/applications/owners/editor/PhabricatorOwnersPackageEditEngine.php
··· 122 122 id(new PhabricatorConduitEditField()) 123 123 ->setKey('paths.set') 124 124 ->setLabel(pht('Paths')) 125 - ->setDescription(pht('Set paths for this package.')) 126 125 ->setIsConduitOnly(true) 127 126 ->setTransactionType(PhabricatorOwnersPackageTransaction::TYPE_PATHS) 127 + ->setConduitDescription( 128 + pht('Overwrite existing package paths with new paths.')) 129 + ->setConduitTypeDescription( 130 + pht('List of dictionaries, each describing a path.')) 128 131 ->setConduitDocumentation($paths_help), 129 132 ); 130 133 }
+21 -13
src/applications/paste/editor/PhabricatorPasteEditEngine.php
··· 59 59 id(new PhabricatorTextEditField()) 60 60 ->setKey('title') 61 61 ->setLabel(pht('Title')) 62 - ->setDescription(pht('Name of the paste.')) 63 62 ->setTransactionType(PhabricatorPasteTransaction::TYPE_TITLE) 63 + ->setDescription(pht('The title of the paste.')) 64 + ->setConduitDescription(pht('Retitle the paste.')) 65 + ->setConduitTypeDescription(pht('New paste title.')) 64 66 ->setValue($object->getTitle()), 65 67 id(new PhabricatorSelectEditField()) 66 68 ->setKey('language') 67 69 ->setLabel(pht('Language')) 70 + ->setTransactionType(PhabricatorPasteTransaction::TYPE_LANGUAGE) 71 + ->setAliases(array('lang')) 72 + ->setIsCopyable(true) 73 + ->setOptions($langs) 68 74 ->setDescription( 69 75 pht( 70 - 'Programming language to interpret the paste as for syntax '. 71 - 'highlighting. By default, the language is inferred from the '. 72 - 'title.')) 73 - ->setAliases(array('lang')) 74 - ->setTransactionType(PhabricatorPasteTransaction::TYPE_LANGUAGE) 75 - ->setIsCopyable(true) 76 - ->setValue($object->getLanguage()) 77 - ->setOptions($langs), 76 + 'Language used for syntax highlighting. By default, inferred '. 77 + 'from the title.')) 78 + ->setConduitDescription( 79 + pht('Change language used for syntax highlighting.')) 80 + ->setConduitTypeDescription(pht('New highlighting language.')) 81 + ->setValue($object->getLanguage()), 78 82 id(new PhabricatorTextAreaEditField()) 79 83 ->setKey('text') 80 84 ->setLabel(pht('Text')) 81 - ->setDescription(pht('The main body text of the paste.')) 82 85 ->setTransactionType(PhabricatorPasteTransaction::TYPE_CONTENT) 83 86 ->setMonospaced(true) 84 87 ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) 88 + ->setDescription(pht('The main body text of the paste.')) 89 + ->setConduitDescription(pht('Change the paste content.')) 90 + ->setConduitTypeDescription(pht('New body content.')) 85 91 ->setValue($object->getRawContent()), 86 92 id(new PhabricatorSelectEditField()) 87 93 ->setKey('status') 88 94 ->setLabel(pht('Status')) 89 - ->setDescription(pht('Active or archive the paste.')) 90 95 ->setTransactionType(PhabricatorPasteTransaction::TYPE_STATUS) 91 96 ->setIsConduitOnly(true) 92 - ->setValue($object->getStatus()) 93 - ->setOptions(PhabricatorPaste::getStatusNameMap()), 97 + ->setOptions(PhabricatorPaste::getStatusNameMap()) 98 + ->setDescription(pht('Active or archived status.')) 99 + ->setConduitDescription(pht('Active or archive the paste.')) 100 + ->setConduitTypeDescription(pht('New paste status constant.')) 101 + ->setValue($object->getStatus()), 94 102 ); 95 103 } 96 104
+6 -3
src/applications/policy/editor/PhabricatorPolicyEditEngineExtension.php
··· 81 81 $policy_field = id(new PhabricatorPolicyEditField()) 82 82 ->setKey($key) 83 83 ->setLabel($label) 84 - ->setDescription($description) 85 84 ->setAliases($aliases) 86 85 ->setIsCopyable(true) 87 86 ->setCapability($capability) 88 87 ->setPolicies($policies) 89 88 ->setTransactionType($type) 90 89 ->setEditTypeKey($edit) 90 + ->setConduitDescription($description) 91 + ->setConduitTypeDescription(pht('New policy PHID or constant.')) 91 92 ->setValue($object->getPolicy($capability)); 92 93 $fields[] = $policy_field; 93 94 ··· 99 100 ->setKey('spacePHID') 100 101 ->setLabel(pht('Space')) 101 102 ->setEditTypeKey('space') 102 - ->setDescription( 103 - pht('Shifts the object in the Spaces application.')) 104 103 ->setIsCopyable(true) 105 104 ->setIsReorderable(false) 106 105 ->setAliases(array('space', 'policy.space')) 107 106 ->setTransactionType($type_space) 107 + ->setDescription(pht('Select a space for the object.')) 108 + ->setConduitDescription( 109 + pht('Shift the object between spaces.')) 110 + ->setConduitTypeDescription(pht('New space PHID.')) 108 111 ->setValue($object->getSpacePHID()); 109 112 $fields[] = $space_field; 110 113
+13 -5
src/applications/project/engineextension/PhabricatorProjectsEditEngineExtension.php
··· 46 46 ->setKey('projectPHIDs') 47 47 ->setLabel(pht('Projects')) 48 48 ->setEditTypeKey('projects') 49 - ->setDescription(pht('Add or remove associated projects.')) 50 49 ->setAliases(array('project', 'projects')) 51 50 ->setIsCopyable(true) 52 51 ->setUseEdgeTransactions(true) 53 - ->setEdgeTransactionDescriptions( 54 - pht('Add projects.'), 55 - pht('Remove projects.'), 56 - pht('Set associated projects, overwriting current value.')) 57 52 ->setCommentActionLabel(pht('Change Projects')) 53 + ->setDescription(pht('Select projects for the object.')) 58 54 ->setTransactionType($edge_type) 59 55 ->setMetadataValue('edge:type', $project_edge_type) 60 56 ->setValue($project_phids); 57 + 58 + $projects_field->setViewer($engine->getViewer()); 59 + 60 + $edit_add = $projects_field->getConduitEditType('projects.add') 61 + ->setConduitDescription(pht('Add projects.')); 62 + 63 + $edit_set = $projects_field->getConduitEditType('projects.set') 64 + ->setConduitDescription( 65 + pht('Set projects, overwriting current value.')); 66 + 67 + $edit_rem = $projects_field->getConduitEditType('projects.remove') 68 + ->setConduitDescription(pht('Remove projects.')); 61 69 62 70 return array( 63 71 $projects_field,
+12 -5
src/applications/subscriptions/engineextension/PhabricatorSubscriptionsEditEngineExtension.php
··· 41 41 ->setKey('subscriberPHIDs') 42 42 ->setLabel(pht('Subscribers')) 43 43 ->setEditTypeKey('subscribers') 44 - ->setDescription(pht('Manage subscribers.')) 45 44 ->setAliases(array('subscriber', 'subscribers')) 46 45 ->setIsCopyable(true) 47 46 ->setUseEdgeTransactions(true) 48 - ->setEdgeTransactionDescriptions( 49 - pht('Add subscribers.'), 50 - pht('Remove subscribers.'), 51 - pht('Set subscribers, overwriting current value.')) 52 47 ->setCommentActionLabel(pht('Change Subscribers')) 53 48 ->setTransactionType($subscribers_type) 54 49 ->setValue($sub_phids); 50 + 51 + $subscribers_field->setViewer($engine->getViewer()); 52 + 53 + $edit_add = $subscribers_field->getConduitEditType('subscribers.add') 54 + ->setConduitDescription(pht('Add subscribers.')); 55 + 56 + $edit_set = $subscribers_field->getConduitEditType('subscribers.set') 57 + ->setConduitDescription( 58 + pht('Set subscribers, overwriting current value.')); 59 + 60 + $edit_rem = $subscribers_field->getConduitEditType('subscribers.remove') 61 + ->setConduitDescription(pht('Remove subscribers.')); 55 62 56 63 return array( 57 64 $subscribers_field,
+28 -7
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 64 64 abstract public function getEngineApplicationClass(); 65 65 abstract protected function buildCustomEditFields($object); 66 66 67 + protected function didBuildCustomEditFields($object, array $fields) { 68 + return; 69 + } 70 + 67 71 public function getFieldsForConfig( 68 72 PhabricatorEditEngineConfiguration $config) { 69 73 ··· 82 86 83 87 $fields = $this->buildCustomEditFields($object); 84 88 89 + foreach ($fields as $field) { 90 + $field 91 + ->setViewer($viewer) 92 + ->setObject($object); 93 + } 94 + 95 + $fields = mpull($fields, null, 'getKey'); 96 + $this->didBuildCustomEditFields($object, $fields); 97 + 85 98 $extensions = PhabricatorEditEngineExtension::getAllEnabledExtensions(); 86 99 foreach ($extensions as $extension) { 87 100 $extension->setViewer($viewer); ··· 96 109 assert_instances_of($extension_fields, 'PhabricatorEditField'); 97 110 98 111 foreach ($extension_fields as $field) { 99 - $fields[] = $field; 112 + $field 113 + ->setViewer($viewer) 114 + ->setObject($object); 115 + } 116 + 117 + $extension_fields = mpull($extension_fields, null, 'getKey'); 118 + $extension->didBuildCustomEditFields($this, $object, $extension_fields); 119 + 120 + foreach ($extension_fields as $key => $field) { 121 + $fields[$key] = $field; 100 122 } 101 123 } 102 124 103 125 $config = $this->getEditEngineConfiguration(); 104 126 $fields = $config->applyConfigurationToFields($this, $object, $fields); 105 - 106 - foreach ($fields as $field) { 107 - $field 108 - ->setViewer($viewer) 109 - ->setObject($object); 110 - } 111 127 112 128 return $fields; 113 129 } ··· 1594 1610 $results = array(); 1595 1611 foreach ($xactions as $xaction) { 1596 1612 $type = $types[$xaction['type']]; 1613 + 1614 + // Let the parameter type interpret the value. This allows you to 1615 + // use usernames in list<user> fields, for example. 1616 + $parameter_type = $type->getConduitParameterType(); 1617 + $xaction['value'] = $parameter_type->getValue($xaction, 'value'); 1597 1618 1598 1619 $type_xactions = $type->generateTransactions( 1599 1620 clone $template,
+6 -11
src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
··· 146 146 ); 147 147 148 148 $key = pht('Key'); 149 - $summary = pht('Summary'); 150 149 $description = pht('Description'); 151 150 $head_type = pht('Type'); 152 151 153 152 $table = array(); 154 - $table[] = "| {$key} | {$summary} |"; 153 + $table[] = "| {$key} | {$description} |"; 155 154 $table[] = '|--------|----------------|'; 156 155 foreach ($types as $type) { 157 156 $edit_type = $type->getEditType(); 158 - $edit_summary = $type->getSummary(); 159 - $table[] = "| `{$edit_type}` | {$edit_summary} |"; 157 + $edit_description = $type->getConduitDescription(); 158 + $table[] = "| `{$edit_type}` | {$edit_description} |"; 160 159 } 161 160 162 161 $out[] = implode("\n", $table); ··· 166 165 $section[] = pht('Edit Type: %s', $type->getEditType()); 167 166 $section[] = '---------'; 168 167 $section[] = null; 169 - $section[] = $type->getDescription(); 168 + $section[] = $type->getConduitDescription(); 170 169 $section[] = null; 171 170 $section[] = pht( 172 171 'This edit generates transactions of type `%s` internally.', ··· 183 182 'Use `%s` to select this edit type.', 184 183 $type->getEditType()); 185 184 186 - $value_type = $type->getValueType(); 187 - if (!strlen($value_type)) { 188 - $value_type = '?'; 189 - } 190 - 191 - $value_description = $type->getValueDescription(); 185 + $value_type = $type->getConduitType(); 186 + $value_description = $type->getConduitTypeDescription(); 192 187 193 188 $table = array(); 194 189 $table[] = "| {$key} | {$head_type} | {$description} |";
+3 -1
src/applications/transactions/editengineextension/PhabricatorCommentEditEngineExtension.php
··· 41 41 $comment_field = id(new PhabricatorCommentEditField()) 42 42 ->setKey('comment') 43 43 ->setLabel(pht('Comments')) 44 - ->setDescription(pht('Add comments.')) 45 44 ->setAliases(array('comments')) 46 45 ->setIsHidden(true) 47 46 ->setIsReorderable(false) 48 47 ->setIsDefaultable(false) 49 48 ->setIsLockable(false) 50 49 ->setTransactionType($comment_type) 50 + ->setConduitDescription(pht('Make comments.')) 51 + ->setConduitTypeDescription( 52 + pht('Comment to add, formatted as remarkup.')) 51 53 ->setValue(null); 52 54 53 55 return array(
+7
src/applications/transactions/editengineextension/PhabricatorEditEngineExtension.php
··· 32 32 PhabricatorEditEngine $engine, 33 33 PhabricatorApplicationTransactionInterface $object); 34 34 35 + public function didBuildCustomEditFields( 36 + PhabricatorEditEngine $engine, 37 + PhabricatorApplicationTransactionInterface $object, 38 + array $fields) { 39 + return; 40 + } 41 + 35 42 final public static function getAllExtensions() { 36 43 return id(new PhutilClassMapQuery()) 37 44 ->setAncestorClass(__CLASS__)
+4
src/applications/transactions/editfield/PhabricatorCommentEditField.php
··· 11 11 return new PhabricatorCommentEditType(); 12 12 } 13 13 14 + protected function newConduitParameterType() { 15 + return new ConduitStringParameterType(); 16 + } 17 + 14 18 public function shouldGenerateTransactionsFromSubmit() { 15 19 return false; 16 20 }
+4
src/applications/transactions/editfield/PhabricatorConduitEditField.php
··· 11 11 return null; 12 12 } 13 13 14 + protected function newConduitParameterType() { 15 + return new ConduitWildParameterType(); 16 + } 17 + 14 18 }
+101 -30
src/applications/transactions/editfield/PhabricatorEditField.php
··· 12 12 private $object; 13 13 private $transactionType; 14 14 private $metadata = array(); 15 - private $description; 16 15 private $editTypeKey; 17 16 private $isRequired; 17 + 18 + private $description; 19 + private $conduitDescription; 18 20 private $conduitDocumentation; 21 + private $conduitTypeDescription; 19 22 20 23 private $commentActionLabel; 21 24 private $commentActionValue; ··· 34 37 private $isLockable = true; 35 38 private $isCopyable = false; 36 39 private $isConduitOnly = false; 40 + 41 + private $conduitEditTypes; 37 42 38 43 public function setKey($key) { 39 44 $this->key = $key; ··· 80 85 return $this->object; 81 86 } 82 87 83 - public function setDescription($description) { 84 - $this->description = $description; 85 - return $this; 86 - } 87 - 88 - public function getDescription() { 89 - return $this->description; 90 - } 91 - 92 88 public function setIsLocked($is_locked) { 93 89 $this->isLocked = $is_locked; 94 90 return $this; ··· 123 119 124 120 public function getIsConduitOnly() { 125 121 return $this->isConduitOnly; 122 + } 123 + 124 + public function setDescription($description) { 125 + $this->description = $description; 126 + return $this; 127 + } 128 + 129 + public function getDescription() { 130 + return $this->description; 131 + } 132 + 133 + public function setConduitDescription($conduit_description) { 134 + $this->conduitDescription = $conduit_description; 135 + return $this; 136 + } 137 + 138 + public function getConduitDescription() { 139 + if ($this->conduitDescription === null) { 140 + return $this->getDescription(); 141 + } 142 + return $this->conduitDescription; 143 + } 144 + 145 + public function setConduitDocumentation($conduit_documentation) { 146 + $this->conduitDocumentation = $conduit_documentation; 147 + return $this; 148 + } 149 + 150 + public function getConduitDocumentation() { 151 + return $this->conduitDocumentation; 152 + } 153 + 154 + public function setConduitTypeDescription($conduit_type_description) { 155 + $this->conduitTypeDescription = $conduit_type_description; 156 + return $this; 157 + } 158 + 159 + public function getConduitTypeDescription() { 160 + return $this->conduitTypeDescription; 126 161 } 127 162 128 163 public function setIsEditDefaults($is_edit_defaults) { ··· 516 551 return new AphrontStringHTTPParameterType(); 517 552 } 518 553 554 + public function getConduitParameterType() { 555 + $type = $this->newConduitParameterType(); 556 + 557 + if (!$type) { 558 + return null; 559 + } 560 + 561 + $type->setViewer($this->getViewer()); 562 + 563 + return $type; 564 + } 565 + 566 + abstract protected function newConduitParameterType(); 567 + 519 568 public function setEditTypeKey($edit_type_key) { 520 569 $this->editTypeKey = $edit_type_key; 521 570 return $this; ··· 529 578 } 530 579 531 580 protected function newEditType() { 532 - // TODO: This could be a little cleaner. 533 - $http_type = $this->getHTTPParameterType(); 534 - if ($http_type) { 535 - $value_type = $http_type->getTypeName(); 536 - } else { 537 - $value_type = 'wild'; 581 + $parameter_type = $this->getConduitParameterType(); 582 + if (!$parameter_type) { 583 + return null; 538 584 } 539 585 540 586 return id(new PhabricatorSimpleEditType()) 541 - ->setValueType($value_type); 587 + ->setConduitParameterType($parameter_type); 542 588 } 543 589 544 590 protected function getEditType() { ··· 549 595 } 550 596 551 597 $type_key = $this->getEditTypeKey(); 598 + $edit_type = $this->newEditType(); 599 + if (!$edit_type) { 600 + return null; 601 + } 552 602 553 - return $this->newEditType() 603 + return $edit_type 554 604 ->setEditType($type_key) 555 605 ->setTransactionType($transaction_type) 556 - ->setDescription($this->getDescription()) 557 - ->setMetadata($this->getMetadata()) 558 - ->setConduitDocumentation($this->getConduitDocumentation()); 606 + ->setMetadata($this->getMetadata()); 607 + } 608 + 609 + final public function getConduitEditTypes() { 610 + if ($this->conduitEditTypes === null) { 611 + $edit_types = $this->newConduitEditTypes(); 612 + $edit_types = mpull($edit_types, null, 'getEditType'); 613 + 614 + foreach ($edit_types as $edit_type) { 615 + $edit_type->setEditField($this); 616 + } 617 + 618 + $this->conduitEditTypes = $edit_types; 619 + } 620 + 621 + return $this->conduitEditTypes; 622 + } 623 + 624 + final public function getConduitEditType($key) { 625 + $edit_types = $this->getConduitEditTypes(); 626 + 627 + if (empty($edit_types[$key])) { 628 + throw new Exception( 629 + pht( 630 + 'This EditField does not provide a Conduit EditType with key "%s".', 631 + $key)); 632 + } 633 + 634 + return $edit_types[$key]; 559 635 } 560 636 561 - public function getConduitEditTypes() { 637 + protected function newConduitEditTypes() { 562 638 $edit_type = $this->getEditType(); 563 639 564 - if ($edit_type === null) { 640 + if (!$edit_type) { 565 641 return array(); 566 642 } 567 643 ··· 679 755 return $edit_type->generateTransactions($template, $spec); 680 756 } 681 757 682 - public function setConduitDocumentation($conduit_documentation) { 683 - $this->conduitDocumentation = $conduit_documentation; 684 - return $this; 685 - } 758 + 759 + 686 760 687 - public function getConduitDocumentation() { 688 - return $this->conduitDocumentation; 689 - } 690 761 691 762 }
+4
src/applications/transactions/editfield/PhabricatorInstructionsEditField.php
··· 11 11 return null; 12 12 } 13 13 14 + protected function newConduitParameterType() { 15 + return null; 16 + } 17 + 14 18 }
+12 -19
src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
··· 4 4 extends PhabricatorEditField { 5 5 6 6 private $useEdgeTransactions; 7 - private $transactionDescriptions = array(); 8 7 private $isSingleValue; 9 8 10 9 public function setUseEdgeTransactions($use_edge_transactions) { ··· 14 13 15 14 public function getUseEdgeTransactions() { 16 15 return $this->useEdgeTransactions; 17 - } 18 - 19 - public function setEdgeTransactionDescriptions($add, $rem, $set) { 20 - $this->transactionDescriptions = array( 21 - '+' => $add, 22 - '-' => $rem, 23 - '=' => $set, 24 - ); 25 - return $this; 26 16 } 27 17 28 18 public function setSingleValue($value) { ··· 42 32 43 33 protected function newHTTPParameterType() { 44 34 return new AphrontPHIDListHTTPParameterType(); 35 + } 36 + 37 + protected function newConduitParameterType() { 38 + return new ConduitPHIDListParameterType(); 45 39 } 46 40 47 41 protected function getValueFromRequest(AphrontRequest $request, $key) { ··· 105 99 return $type; 106 100 } 107 101 108 - public function getConduitEditTypes() { 102 + protected function newConduitEditTypes() { 109 103 if (!$this->getUseEdgeTransactions()) { 110 - return parent::getConduitEditTypes(); 104 + return parent::newConduitEditTypes(); 111 105 } 112 106 113 107 $transaction_type = $this->getTransactionType(); ··· 116 110 } 117 111 118 112 $type_key = $this->getEditTypeKey(); 119 - $strings = $this->transactionDescriptions; 120 113 121 114 $base = $this->getEditType(); 122 115 123 116 $add = id(clone $base) 124 117 ->setEditType($type_key.'.add') 125 118 ->setEdgeOperation('+') 126 - ->setDescription(idx($strings, '+')) 127 - ->setValueDescription(pht('List of PHIDs to add.')); 119 + ->setConduitTypeDescription(pht('List of PHIDs to add.')) 120 + ->setConduitParameterType($this->getConduitParameterType()); 128 121 129 122 $rem = id(clone $base) 130 123 ->setEditType($type_key.'.remove') 131 124 ->setEdgeOperation('-') 132 - ->setDescription(idx($strings, '-')) 133 - ->setValueDescription(pht('List of PHIDs to remove.')); 125 + ->setConduitTypeDescription(pht('List of PHIDs to remove.')) 126 + ->setConduitParameterType($this->getConduitParameterType()); 134 127 135 128 $set = id(clone $base) 136 129 ->setEditType($type_key.'.set') 137 130 ->setEdgeOperation('=') 138 - ->setDescription(idx($strings, '=')) 139 - ->setValueDescription(pht('List of PHIDs to set.')); 131 + ->setConduitTypeDescription(pht('List of PHIDs to set.')) 132 + ->setConduitParameterType($this->getConduitParameterType()); 140 133 141 134 return array( 142 135 $add,
+5
src/applications/transactions/editfield/PhabricatorPolicyEditField.php
··· 55 55 return new AphrontPHIDHTTPParameterType(); 56 56 } 57 57 58 + protected function newConduitParameterType() { 59 + return new ConduitStringParameterType(); 60 + } 61 + 62 + 58 63 }
+4
src/applications/transactions/editfield/PhabricatorProjectsEditField.php
··· 11 11 return new AphrontProjectListHTTPParameterType(); 12 12 } 13 13 14 + protected function newConduitParameterType() { 15 + return new ConduitProjectListParameterType(); 16 + } 17 + 14 18 }
+4
src/applications/transactions/editfield/PhabricatorRemarkupEditField.php
··· 7 7 return new PhabricatorRemarkupControl(); 8 8 } 9 9 10 + protected function newConduitParameterType() { 11 + return new ConduitStringParameterType(); 12 + } 13 + 10 14 }
+4
src/applications/transactions/editfield/PhabricatorSelectEditField.php
··· 31 31 ->setOptions($this->getOptions()); 32 32 } 33 33 34 + protected function newConduitParameterType() { 35 + return new ConduitStringParameterType(); 36 + } 37 + 34 38 }
+4
src/applications/transactions/editfield/PhabricatorSpaceEditField.php
··· 13 13 return new AphrontPHIDHTTPParameterType(); 14 14 } 15 15 16 + protected function newConduitParameterType() { 17 + return new ConduitPHIDParameterType(); 18 + } 19 + 16 20 }
+4
src/applications/transactions/editfield/PhabricatorSubscribersEditField.php
··· 13 13 return new AphrontUserListHTTPParameterType(); 14 14 } 15 15 16 + protected function newConduitParameterType() { 17 + return new ConduitUserListParameterType(); 18 + } 19 + 16 20 }
+4
src/applications/transactions/editfield/PhabricatorTextAreaEditField.php
··· 39 39 return $control; 40 40 } 41 41 42 + protected function newConduitParameterType() { 43 + return new ConduitStringParameterType(); 44 + } 45 + 42 46 }
+4
src/applications/transactions/editfield/PhabricatorTextEditField.php
··· 7 7 return new AphrontFormTextControl(); 8 8 } 9 9 10 + protected function newConduitParameterType() { 11 + return new ConduitStringParameterType(); 12 + } 13 + 10 14 }
+4
src/applications/transactions/editfield/PhabricatorUsersEditField.php
··· 11 11 return new AphrontUserListHTTPParameterType(); 12 12 } 13 13 14 + protected function newConduitParameterType() { 15 + return new ConduitUserListParameterType(); 16 + } 17 + 14 18 }
+2 -6
src/applications/transactions/edittype/PhabricatorCommentEditType.php
··· 2 2 3 3 final class PhabricatorCommentEditType extends PhabricatorEditType { 4 4 5 - public function getValueType() { 6 - return id(new AphrontStringHTTPParameterType())->getTypeName(); 5 + protected function newConduitParameterType() { 6 + return new ConduitStringParameterType(); 7 7 } 8 8 9 9 public function generateTransactions( ··· 17 17 ->attachComment($comment); 18 18 19 19 return array($xaction); 20 - } 21 - 22 - public function getValueDescription() { 23 - return pht('Comment to add, formated as remarkup.'); 24 20 } 25 21 26 22 }
-9
src/applications/transactions/edittype/PhabricatorEdgeEditType.php
··· 34 34 return array($xaction); 35 35 } 36 36 37 - public function setValueDescription($value_description) { 38 - $this->valueDescription = $value_description; 39 - return $this; 40 - } 41 - 42 - public function getValueDescription() { 43 - return $this->valueDescription; 44 - } 45 - 46 37 }
+84 -35
src/applications/transactions/edittype/PhabricatorEditType.php
··· 3 3 abstract class PhabricatorEditType extends Phobject { 4 4 5 5 private $editType; 6 + private $editField; 6 7 private $transactionType; 7 8 private $label; 8 9 private $field; 9 - private $description; 10 - private $summary; 11 10 private $metadata = array(); 12 - private $conduitDocumentation; 13 11 14 - public function setDescription($description) { 15 - $this->description = $description; 16 - return $this; 17 - } 18 - 19 - public function getDescription() { 20 - return $this->description; 21 - } 22 - 23 - public function setSummary($summary) { 24 - $this->summary = $summary; 25 - return $this; 26 - } 27 - 28 - public function getSummary() { 29 - if ($this->summary === null) { 30 - return $this->getDescription(); 31 - } 32 - return $this->summary; 33 - } 12 + private $conduitDescription; 13 + private $conduitDocumentation; 14 + private $conduitTypeDescription; 15 + private $conduitParameterType; 34 16 35 17 public function setLabel($label) { 36 18 $this->label = $label; ··· 59 41 return $this->editType; 60 42 } 61 43 62 - public function setConduitDocumentation($conduit_documentation) { 63 - $this->conduitDocumentation = $conduit_documentation; 64 - return $this; 65 - } 66 - 67 - public function getConduitDocumentation() { 68 - return $this->conduitDocumentation; 69 - } 70 - 71 44 public function setMetadata($metadata) { 72 45 $this->metadata = $metadata; 73 46 return $this; ··· 90 63 PhabricatorApplicationTransaction $template, 91 64 array $spec); 92 65 93 - abstract public function getValueType(); 94 - abstract public function getValueDescription(); 95 - 96 66 protected function newTransaction( 97 67 PhabricatorApplicationTransaction $template) { 98 68 ··· 104 74 } 105 75 106 76 return $xaction; 77 + } 78 + 79 + public function setEditField(PhabricatorEditField $edit_field) { 80 + $this->editField = $edit_field; 81 + return $this; 82 + } 83 + 84 + public function getEditField() { 85 + return $this->editField; 86 + } 87 + 88 + /* -( Conduit )------------------------------------------------------------ */ 89 + 90 + 91 + protected function newConduitParameterType() { 92 + if ($this->conduitParameterType) { 93 + return clone $this->conduitParameterType; 94 + } 95 + 96 + return null; 97 + } 98 + 99 + public function setConduitParameterType(ConduitParameterType $type) { 100 + $this->conduitParameterType = $type; 101 + return $this; 102 + } 103 + 104 + public function getConduitParameterType() { 105 + return $this->newConduitParameterType(); 106 + } 107 + 108 + public function getConduitType() { 109 + $parameter_type = $this->getConduitParameterType(); 110 + return $parameter_type->getTypeName(); 111 + } 112 + 113 + public function setConduitTypeDescription($conduit_type_description) { 114 + $this->conduitTypeDescription = $conduit_type_description; 115 + return $this; 116 + } 117 + 118 + public function getConduitTypeDescription() { 119 + if ($this->conduitTypeDescription === null) { 120 + if ($this->getEditField()) { 121 + return $this->getEditField()->getConduitTypeDescription(); 122 + } 123 + } 124 + 125 + return $this->conduitTypeDescription; 126 + } 127 + 128 + public function setConduitDescription($conduit_description) { 129 + $this->conduitDescription = $conduit_description; 130 + return $this; 131 + } 132 + 133 + public function getConduitDescription() { 134 + if ($this->conduitDescription === null) { 135 + if ($this->getEditField()) { 136 + return $this->getEditField()->getConduitDescription(); 137 + } 138 + } 139 + 140 + return $this->conduitDescription; 141 + } 142 + 143 + public function setConduitDocumentation($conduit_documentation) { 144 + $this->conduitDocumentation = $conduit_documentation; 145 + return $this; 146 + } 147 + 148 + public function getConduitDocumentation() { 149 + if ($this->conduitDocumentation === null) { 150 + if ($this->getEditField()) { 151 + return $this->getEditField()->getConduitDocumentation(); 152 + } 153 + } 154 + 155 + return $this->conduitDocumentation; 107 156 } 108 157 109 158 }
+13
src/applications/transactions/edittype/PhabricatorPHIDListEditType.php
··· 42 42 } 43 43 } 44 44 45 + protected function newConduitParameterType() { 46 + $default = parent::newConduitParameterType(); 47 + if ($default) { 48 + return $default; 49 + } 50 + 51 + if ($this->getIsSingleValue()) { 52 + return new ConduitPHIDParameterType(); 53 + } else { 54 + return new ConduitPHIDListParameterType(); 55 + } 56 + } 57 + 45 58 }
-23
src/applications/transactions/edittype/PhabricatorSimpleEditType.php
··· 2 2 3 3 final class PhabricatorSimpleEditType extends PhabricatorEditType { 4 4 5 - private $valueType; 6 - private $valueDescription; 7 - private $phuixControlType; 8 - private $phuixControlSpecification = array(); 9 - 10 - public function setValueType($value_type) { 11 - $this->valueType = $value_type; 12 - return $this; 13 - } 14 - 15 - public function getValueType() { 16 - return $this->valueType; 17 - } 18 - 19 5 public function generateTransactions( 20 6 PhabricatorApplicationTransaction $template, 21 7 array $spec) { ··· 24 10 ->setNewValue(idx($spec, 'value')); 25 11 26 12 return array($edit); 27 - } 28 - 29 - public function setValueDescription($value_description) { 30 - $this->valueDescription = $value_description; 31 - return $this; 32 - } 33 - 34 - public function getValueDescription() { 35 - return $this->valueDescription; 36 13 } 37 14 38 15 }
+30 -8
src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php
··· 5 5 6 6 private $customField; 7 7 private $httpParameterType; 8 + private $conduitParameterType; 8 9 9 10 public function setCustomField(PhabricatorCustomField $custom_field) { 10 11 $this->customField = $custom_field; ··· 25 26 return $this->httpParameterType; 26 27 } 27 28 29 + public function setCustomFieldConduitParameterType( 30 + ConduitParameterType $type) { 31 + $this->conduitParameterType = $type; 32 + return $this; 33 + } 34 + 35 + public function getCustomFieldConduitParameterType() { 36 + return $this->conduitParameterType; 37 + } 38 + 28 39 protected function buildControl() { 29 40 $field = $this->getCustomField(); 30 41 $clone = clone $field; ··· 36 47 } 37 48 38 49 protected function newEditType() { 39 - $type = id(new PhabricatorCustomFieldEditType()) 40 - ->setCustomField($this->getCustomField()); 41 - 42 - $http_type = $this->getHTTPParameterType(); 43 - if ($http_type) { 44 - $type->setValueType($http_type->getTypeName()); 50 + $conduit_type = $this->newConduitParameterType(); 51 + if (!$conduit_type) { 52 + return null; 45 53 } 54 + 55 + $type = id(new PhabricatorCustomFieldEditType()) 56 + ->setCustomField($this->getCustomField()) 57 + ->setConduitParameterType($conduit_type); 46 58 47 59 return $type; 48 60 } ··· 71 83 return $clone->getNewValueForApplicationTransactions(); 72 84 } 73 85 74 - public function getConduitEditTypes() { 86 + protected function newConduitEditTypes() { 75 87 $field = $this->getCustomField(); 76 88 77 89 if (!$field->shouldAppearInConduitTransactions()) { 78 90 return array(); 79 91 } 80 92 81 - return parent::getConduitEditTypes(); 93 + return parent::newConduitEditTypes(); 82 94 } 83 95 84 96 protected function newHTTPParameterType() { 85 97 $type = $this->getCustomFieldHTTPParameterType(); 98 + 99 + if ($type) { 100 + return clone $type; 101 + } 102 + 103 + return null; 104 + } 105 + 106 + protected function newConduitParameterType() { 107 + $type = $this->getCustomFieldConduitParameterType(); 86 108 87 109 if ($type) { 88 110 return clone $type;
-15
src/infrastructure/customfield/editor/PhabricatorCustomFieldEditType.php
··· 4 4 extends PhabricatorEditType { 5 5 6 6 private $customField; 7 - private $valueType; 8 7 9 8 public function setCustomField(PhabricatorCustomField $custom_field) { 10 9 $this->customField = $custom_field; ··· 15 14 return $this->customField; 16 15 } 17 16 18 - public function setValueType($value_type) { 19 - $this->valueType = $value_type; 20 - return $this; 21 - } 22 - 23 - public function getValueType() { 24 - return $this->valueType; 25 - } 26 - 27 17 public function getMetadata() { 28 18 $field = $this->getCustomField(); 29 19 return parent::getMetadata() + $field->getApplicationTransactionMetadata(); 30 - } 31 - 32 - public function getValueDescription() { 33 - $field = $this->getCustomField(); 34 - return $field->getFieldDescription(); 35 20 } 36 21 37 22 public function generateTransactions(
+16
src/infrastructure/customfield/field/PhabricatorCustomField.php
··· 1106 1106 $field->setCustomFieldHTTPParameterType($http_type); 1107 1107 } 1108 1108 1109 + $conduit_type = $this->getConduitEditParameterType(); 1110 + if ($conduit_type) { 1111 + $field->setCustomFieldConduitParameterType($conduit_type); 1112 + } 1113 + 1109 1114 return $field; 1110 1115 } 1111 1116 ··· 1344 1349 protected function newConduitSearchParameterType() { 1345 1350 if ($this->proxy) { 1346 1351 return $this->proxy->newConduitSearchParameterType(); 1352 + } 1353 + return null; 1354 + } 1355 + 1356 + public function getConduitEditParameterType() { 1357 + return $this->newConduitEditParameterType(); 1358 + } 1359 + 1360 + protected function newConduitEditParameterType() { 1361 + if ($this->proxy) { 1362 + return $this->proxy->newConduitEditParameterType(); 1347 1363 } 1348 1364 return null; 1349 1365 }
+5
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
··· 136 136 protected function newConduitSearchParameterType() { 137 137 return new ConduitBoolParameterType(); 138 138 } 139 + 140 + protected function newConduitEditParameterType() { 141 + return new ConduitBoolParameterType(); 142 + } 143 + 139 144 }
+4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldDate.php
··· 202 202 return null; 203 203 } 204 204 205 + protected function newConduitEditParameterType() { 206 + return new ConduitEpochParameterType(); 207 + } 208 + 205 209 }
+4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php
··· 120 120 return new ConduitIntParameterType(); 121 121 } 122 122 123 + protected function newConduitEditParameterType() { 124 + return new ConduitIntParameterType(); 125 + } 126 + 123 127 }
+5
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php
··· 87 87 protected function newConduitSearchParameterType() { 88 88 return new ConduitStringListParameterType(); 89 89 } 90 + 91 + protected function newConduitEditParameterType() { 92 + return new ConduitStringParameterType(); 93 + } 94 + 90 95 }
+5
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldSelect.php
··· 143 143 protected function newConduitSearchParameterType() { 144 144 return new ConduitStringListParameterType(); 145 145 } 146 + 147 + protected function newConduitEditParameterType() { 148 + return new ConduitStringParameterType(); 149 + } 150 + 146 151 }
+4
src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldUsers.php
··· 19 19 return new ConduitUserListParameterType(); 20 20 } 21 21 22 + protected function newConduitEditParameterType() { 23 + return new ConduitUserListParameterType(); 24 + } 25 + 22 26 }