Differential D12129 Diff 29186 src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
Show First 20 Lines • Show All 288 Lines • ▼ Show 20 Lines | private function getTransactionNewValue( | ||||
switch ($xaction->getTransactionType()) { | switch ($xaction->getTransactionType()) { | ||||
case PhabricatorTransactions::TYPE_SUBSCRIBERS: | case PhabricatorTransactions::TYPE_SUBSCRIBERS: | ||||
return $this->getPHIDTransactionNewValue($xaction); | return $this->getPHIDTransactionNewValue($xaction); | ||||
case PhabricatorTransactions::TYPE_VIEW_POLICY: | case PhabricatorTransactions::TYPE_VIEW_POLICY: | ||||
case PhabricatorTransactions::TYPE_EDIT_POLICY: | case PhabricatorTransactions::TYPE_EDIT_POLICY: | ||||
case PhabricatorTransactions::TYPE_JOIN_POLICY: | case PhabricatorTransactions::TYPE_JOIN_POLICY: | ||||
case PhabricatorTransactions::TYPE_BUILDABLE: | case PhabricatorTransactions::TYPE_BUILDABLE: | ||||
case PhabricatorTransactions::TYPE_TOKEN: | case PhabricatorTransactions::TYPE_TOKEN: | ||||
case PhabricatorTransactions::TYPE_INLINESTATE: | |||||
return $xaction->getNewValue(); | return $xaction->getNewValue(); | ||||
case PhabricatorTransactions::TYPE_EDGE: | case PhabricatorTransactions::TYPE_EDGE: | ||||
return $this->getEdgeTransactionNewValue($xaction); | return $this->getEdgeTransactionNewValue($xaction); | ||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
$field = $this->getCustomFieldForTransaction($object, $xaction); | $field = $this->getCustomFieldForTransaction($object, $xaction); | ||||
return $field->getNewValueFromApplicationTransactions($xaction); | return $field->getNewValueFromApplicationTransactions($xaction); | ||||
case PhabricatorTransactions::TYPE_COMMENT: | case PhabricatorTransactions::TYPE_COMMENT: | ||||
return null; | return null; | ||||
▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
$object->setViewPolicy($xaction->getNewValue()); | $object->setViewPolicy($xaction->getNewValue()); | ||||
break; | break; | ||||
case PhabricatorTransactions::TYPE_EDIT_POLICY: | case PhabricatorTransactions::TYPE_EDIT_POLICY: | ||||
$object->setEditPolicy($xaction->getNewValue()); | $object->setEditPolicy($xaction->getNewValue()); | ||||
break; | break; | ||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
$field = $this->getCustomFieldForTransaction($object, $xaction); | $field = $this->getCustomFieldForTransaction($object, $xaction); | ||||
return $field->applyApplicationTransactionInternalEffects($xaction); | return $field->applyApplicationTransactionInternalEffects($xaction); | ||||
case PhabricatorTransactions::TYPE_INLINESTATE: | |||||
return $this->applyBuiltinInternalTransaction($object, $xaction); | |||||
} | } | ||||
return $this->applyCustomInternalTransaction($object, $xaction); | return $this->applyCustomInternalTransaction($object, $xaction); | ||||
} | } | ||||
private function applyExternalEffects( | private function applyExternalEffects( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
▲ Show 20 Lines • Show All 78 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
$editor->addEdge($src, $const, $dst_phid, $data); | $editor->addEdge($src, $const, $dst_phid, $data); | ||||
} | } | ||||
$editor->save(); | $editor->save(); | ||||
break; | break; | ||||
case PhabricatorTransactions::TYPE_CUSTOMFIELD: | case PhabricatorTransactions::TYPE_CUSTOMFIELD: | ||||
$field = $this->getCustomFieldForTransaction($object, $xaction); | $field = $this->getCustomFieldForTransaction($object, $xaction); | ||||
return $field->applyApplicationTransactionExternalEffects($xaction); | return $field->applyApplicationTransactionExternalEffects($xaction); | ||||
case PhabricatorTransactions::TYPE_INLINESTATE: | |||||
return $this->applyBuiltinExternalTransaction($object, $xaction); | |||||
} | } | ||||
return $this->applyCustomExternalTransaction($object, $xaction); | return $this->applyCustomExternalTransaction($object, $xaction); | ||||
} | } | ||||
protected function applyCustomInternalTransaction( | protected function applyCustomInternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
$type = $xaction->getTransactionType(); | $type = $xaction->getTransactionType(); | ||||
throw new Exception( | throw new Exception( | ||||
"Transaction type '{$type}' is missing an internal apply ". | "Transaction type '{$type}' is missing an internal apply ". | ||||
"implementation!"); | "implementation!"); | ||||
} | } | ||||
protected function applyCustomExternalTransaction( | protected function applyCustomExternalTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
$type = $xaction->getTransactionType(); | $type = $xaction->getTransactionType(); | ||||
throw new Exception( | throw new Exception( | ||||
"Transaction type '{$type}' is missing an external apply ". | "Transaction type '{$type}' is missing an external apply ". | ||||
"implementation!"); | "implementation!"); | ||||
} | } | ||||
// TODO: Write proper documentation for these hooks. These are like the | |||||
// "applyCustom" hooks, except that implementation is optional, so you do | |||||
// not need to handle all of the builtin transaction types. See T6403. These | |||||
// are not completely implemented. | |||||
protected function applyBuiltinInternalTransaction( | |||||
PhabricatorLiskDAO $object, | |||||
PhabricatorApplicationTransaction $xaction) { | |||||
return; | |||||
} | |||||
protected function applyBuiltinExternalTransaction( | |||||
PhabricatorLiskDAO $object, | |||||
PhabricatorApplicationTransaction $xaction) { | |||||
return; | |||||
} | |||||
/** | /** | ||||
* Fill in a transaction's common values, like author and content source. | * Fill in a transaction's common values, like author and content source. | ||||
*/ | */ | ||||
protected function populateTransaction( | protected function populateTransaction( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
PhabricatorApplicationTransaction $xaction) { | PhabricatorApplicationTransaction $xaction) { | ||||
$actor = $this->getActor(); | $actor = $this->getActor(); | ||||
▲ Show 20 Lines • Show All 2,116 Lines • Show Last 20 Lines |