Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13956682
D14607.id35332.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
10 KB
Referenced Files
None
Subscribers
None
D14607.id35332.diff
View Options
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngine.php b/src/applications/transactions/editengine/PhabricatorEditEngine.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngine.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngine.php
@@ -630,13 +630,22 @@
$xactions = array();
foreach ($fields as $field) {
- $xaction = $field->generateTransaction(clone $template);
+ $types = $field->getWebEditTypes();
+ foreach ($types as $type) {
+ $type_xactions = $type->generateTransactions(
+ clone $template,
+ array(
+ 'value' => $field->getValueForTransaction(),
+ ));
+
+ if (!$type_xactions) {
+ continue;
+ }
- if (!$xaction) {
- continue;
+ foreach ($type_xactions as $type_xaction) {
+ $xactions[] = $type_xaction;
+ }
}
-
- $xactions[] = $xaction;
}
$editor = $object->getApplicationTransactionEditor()
@@ -941,7 +950,7 @@
$fields = $this->buildEditFields($object);
- $types = $this->getAllEditTypesFromFields($fields);
+ $types = $this->getConduitEditTypesFromFields($fields);
$template = $object->getApplicationTransactionTemplate();
$xactions = $this->getConduitTransactions($request, $types, $template);
@@ -1031,9 +1040,13 @@
foreach ($xactions as $xaction) {
$type = $types[$xaction['type']];
- $results[] = $type->generateTransaction(
+ $type_xactions = $type->generateTransactions(
clone $template,
$xaction);
+
+ foreach ($type_xactions as $type_xaction) {
+ $results[] = $type_xaction;
+ }
}
return $results;
@@ -1044,10 +1057,10 @@
* @return map<string, PhabricatorEditType>
* @task conduit
*/
- private function getAllEditTypesFromFields(array $fields) {
+ private function getConduitEditTypesFromFields(array $fields) {
$types = array();
foreach ($fields as $field) {
- $field_types = $field->getEditTransactionTypes();
+ $field_types = $field->getConduitEditTypes();
if ($field_types === null) {
continue;
@@ -1061,7 +1074,7 @@
return $types;
}
- public function getAllEditTypes() {
+ public function getConduitEditTypes() {
$config = $this->loadEditEngineConfiguration(null);
if (!$config) {
return array();
@@ -1069,7 +1082,7 @@
$object = $this->newEditableObject();
$fields = $this->buildEditFields($object);
- return $this->getAllEditTypesFromFields($fields);
+ return $this->getConduitEditTypesFromFields($fields);
}
final public static function getAllEditEngines() {
diff --git a/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php b/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
--- a/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
+++ b/src/applications/transactions/editengine/PhabricatorEditEngineAPIMethod.php
@@ -44,7 +44,7 @@
$engine = $this->newEditEngine()
->setViewer($viewer);
- $types = $engine->getAllEditTypes();
+ $types = $engine->getConduitEditTypes();
$out = array();
diff --git a/src/applications/transactions/editfield/PhabricatorCommentEditField.php b/src/applications/transactions/editfield/PhabricatorCommentEditField.php
--- a/src/applications/transactions/editfield/PhabricatorCommentEditField.php
+++ b/src/applications/transactions/editfield/PhabricatorCommentEditField.php
@@ -11,15 +11,4 @@
return new PhabricatorCommentEditType();
}
- public function generateTransaction(
- PhabricatorApplicationTransaction $xaction) {
-
- $spec = array(
- 'value' => $this->getValueForTransaction(),
- );
-
- return head($this->getEditTransactionTypes())
- ->generateTransaction($xaction, $spec);
- }
-
}
diff --git a/src/applications/transactions/editfield/PhabricatorEditField.php b/src/applications/transactions/editfield/PhabricatorEditField.php
--- a/src/applications/transactions/editfield/PhabricatorEditField.php
+++ b/src/applications/transactions/editfield/PhabricatorEditField.php
@@ -268,24 +268,6 @@
return $this;
}
- public function generateTransaction(
- PhabricatorApplicationTransaction $xaction) {
-
- if (!$this->getTransactionType()) {
- return null;
- }
-
- $xaction
- ->setTransactionType($this->getTransactionType())
- ->setNewValue($this->getValueForTransaction());
-
- foreach ($this->metadata as $key => $value) {
- $xaction->setMetadataValue($key, $value);
- }
-
- return $xaction;
- }
-
public function setMetadataValue($key, $value) {
$this->metadata[$key] = $value;
return $this;
@@ -295,7 +277,7 @@
return $this->metadata;
}
- protected function getValueForTransaction() {
+ public function getValueForTransaction() {
return $this->getValue();
}
@@ -449,7 +431,7 @@
->setValueType($this->getHTTPParameterType()->getTypeName());
}
- protected function getEditTransactionType() {
+ protected function getEditType() {
$transaction_type = $this->getTransactionType();
if ($transaction_type === null) {
@@ -465,8 +447,18 @@
->setMetadata($this->getMetadata());
}
- public function getEditTransactionTypes() {
- $edit_type = $this->getEditTransactionType();
+ public function getConduitEditTypes() {
+ $edit_type = $this->getEditType();
+
+ if ($edit_type === null) {
+ return null;
+ }
+
+ return array($edit_type);
+ }
+
+ public function getWebEditTypes() {
+ $edit_type = $this->getEditType();
if ($edit_type === null) {
return null;
diff --git a/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php b/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
--- a/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
+++ b/src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
@@ -28,7 +28,7 @@
return new AphrontPHIDListHTTPParameterType();
}
- protected function getValueForTransaction() {
+ public function getValueForTransaction() {
$new = parent::getValueForTransaction();
if (!$this->getUseEdgeTransactions()) {
@@ -71,9 +71,9 @@
return parent::newEditType();
}
- public function getEditTransactionTypes() {
+ public function getConduitEditTypes() {
if (!$this->getUseEdgeTransactions()) {
- return parent::getEditTransactionTypes();
+ return parent::getConduitEditTypes();
}
$transaction_type = $this->getTransactionType();
@@ -84,7 +84,7 @@
$type_key = $this->getEditTypeKey();
$strings = $this->transactionDescriptions;
- $base = $this->getEditTransactionType();
+ $base = $this->getEditType();
$add = id(clone $base)
->setEditType($type_key.'.add')
diff --git a/src/applications/transactions/edittype/PhabricatorCommentEditType.php b/src/applications/transactions/edittype/PhabricatorCommentEditType.php
--- a/src/applications/transactions/edittype/PhabricatorCommentEditType.php
+++ b/src/applications/transactions/edittype/PhabricatorCommentEditType.php
@@ -6,22 +6,17 @@
return id(new AphrontStringHTTPParameterType())->getTypeName();
}
- public function generateTransaction(
+ public function generateTransactions(
PhabricatorApplicationTransaction $template,
array $spec) {
$comment = $template->getApplicationTransactionCommentObject()
->setContent(idx($spec, 'value'));
- $template
- ->setTransactionType($this->getTransactionType())
+ $xaction = $this->newTransaction($template)
->attachComment($comment);
- foreach ($this->getMetadata() as $key => $value) {
- $template->setMetadataValue($key, $value);
- }
-
- return $template;
+ return array($xaction);
}
public function getValueDescription() {
diff --git a/src/applications/transactions/edittype/PhabricatorEdgeEditType.php b/src/applications/transactions/edittype/PhabricatorEdgeEditType.php
--- a/src/applications/transactions/edittype/PhabricatorEdgeEditType.php
+++ b/src/applications/transactions/edittype/PhabricatorEdgeEditType.php
@@ -18,25 +18,23 @@
return 'list<phid>';
}
- public function generateTransaction(
+ public function generateTransactions(
PhabricatorApplicationTransaction $template,
array $spec) {
$value = idx($spec, 'value');
- $value = array_fuse($value);
- $value = array(
- $this->getEdgeOperation() => $value,
- );
- $template
- ->setTransactionType($this->getTransactionType())
- ->setNewValue($value);
-
- foreach ($this->getMetadata() as $key => $value) {
- $template->setMetadataValue($key, $value);
+ if ($this->getEdgeOperation() !== null) {
+ $value = array_fuse($value);
+ $value = array(
+ $this->getEdgeOperation() => $value,
+ );
}
- return $template;
+ $xaction = $this->newTransaction($template)
+ ->setNewValue($value);
+
+ return array($xaction);
}
public function setValueDescription($value_description) {
diff --git a/src/applications/transactions/edittype/PhabricatorEditType.php b/src/applications/transactions/edittype/PhabricatorEditType.php
--- a/src/applications/transactions/edittype/PhabricatorEditType.php
+++ b/src/applications/transactions/edittype/PhabricatorEditType.php
@@ -66,11 +66,24 @@
return $this->transactionType;
}
- abstract public function generateTransaction(
+ abstract public function generateTransactions(
PhabricatorApplicationTransaction $template,
array $spec);
abstract public function getValueType();
abstract public function getValueDescription();
+ protected function newTransaction(
+ PhabricatorApplicationTransaction $template) {
+
+ $xaction = id(clone $template)
+ ->setTransactionType($this->getTransactionType());
+
+ foreach ($this->getMetadata() as $key => $value) {
+ $xaction->setMetadataValue($key, $value);
+ }
+
+ return $xaction;
+ }
+
}
diff --git a/src/applications/transactions/edittype/PhabricatorSimpleEditType.php b/src/applications/transactions/edittype/PhabricatorSimpleEditType.php
--- a/src/applications/transactions/edittype/PhabricatorSimpleEditType.php
+++ b/src/applications/transactions/edittype/PhabricatorSimpleEditType.php
@@ -14,19 +14,14 @@
return $this->valueType;
}
- public function generateTransaction(
+ public function generateTransactions(
PhabricatorApplicationTransaction $template,
array $spec) {
- $template
- ->setTransactionType($this->getTransactionType())
+ $edit = $this->newTransaction($template)
->setNewValue(idx($spec, 'value'));
- foreach ($this->getMetadata() as $key => $value) {
- $template->setMetadataValue($key, $value);
- }
-
- return $template;
+ return array($edit);
}
public function setValueDescription($value_description) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 15 2024, 6:43 AM (5 w, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6711753
Default Alt Text
D14607.id35332.diff (10 KB)
Attached To
Mode
D14607: Consolidate transaction generation in EditType objects
Attached
Detach File
Event Timeline
Log In to Comment