Differential D14666 Diff 35490 src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorPHIDListEditField.php
| <?php | <?php | ||||
| abstract class PhabricatorPHIDListEditField | abstract class PhabricatorPHIDListEditField | ||||
| extends PhabricatorEditField { | extends PhabricatorEditField { | ||||
| private $useEdgeTransactions; | private $useEdgeTransactions; | ||||
| private $transactionDescriptions = array(); | private $transactionDescriptions = array(); | ||||
| private $isSingleValue; | |||||
| public function setUseEdgeTransactions($use_edge_transactions) { | public function setUseEdgeTransactions($use_edge_transactions) { | ||||
| $this->useEdgeTransactions = $use_edge_transactions; | $this->useEdgeTransactions = $use_edge_transactions; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getUseEdgeTransactions() { | public function getUseEdgeTransactions() { | ||||
| return $this->useEdgeTransactions; | return $this->useEdgeTransactions; | ||||
| } | } | ||||
| public function setEdgeTransactionDescriptions($add, $rem, $set) { | public function setEdgeTransactionDescriptions($add, $rem, $set) { | ||||
| $this->transactionDescriptions = array( | $this->transactionDescriptions = array( | ||||
| '+' => $add, | '+' => $add, | ||||
| '-' => $rem, | '-' => $rem, | ||||
| '=' => $set, | '=' => $set, | ||||
| ); | ); | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setSingleValue($value) { | |||||
| if ($value === null) { | |||||
| $value = array(); | |||||
| } else { | |||||
| $value = array($value); | |||||
| } | |||||
| $this->isSingleValue = true; | |||||
| return $this->setValue($value); | |||||
| } | |||||
| public function getIsSingleValue() { | |||||
| return $this->isSingleValue; | |||||
| } | |||||
| protected function newHTTPParameterType() { | protected function newHTTPParameterType() { | ||||
| return new AphrontPHIDListHTTPParameterType(); | return new AphrontPHIDListHTTPParameterType(); | ||||
| } | } | ||||
| public function getValueForTransaction() { | public function getValueForTransaction() { | ||||
| $new = parent::getValueForTransaction(); | $new = parent::getValueForTransaction(); | ||||
| if ($this->getIsSingleValue()) { | |||||
| if ($new) { | |||||
| return head($new); | |||||
| } else { | |||||
| return null; | |||||
| } | |||||
| } | |||||
| if (!$this->getUseEdgeTransactions()) { | if (!$this->getUseEdgeTransactions()) { | ||||
| return $new; | return $new; | ||||
| } | } | ||||
| $old = $this->getInitialValue(); | $old = $this->getInitialValue(); | ||||
| if ($old === null) { | if ($old === null) { | ||||
| return array( | return array( | ||||
| '=' => array_fuse($new), | '=' => array_fuse($new), | ||||
| Show All 21 Lines | public function getValueForTransaction() { | ||||
| return $value; | return $value; | ||||
| } | } | ||||
| protected function newEditType() { | protected function newEditType() { | ||||
| if ($this->getUseEdgeTransactions()) { | if ($this->getUseEdgeTransactions()) { | ||||
| return new PhabricatorEdgeEditType(); | return new PhabricatorEdgeEditType(); | ||||
| } | } | ||||
| return parent::newEditType(); | $type = parent::newEditType(); | ||||
| if ($this->getIsSingleValue()) { | |||||
| $type->setValueType('phid'); | |||||
| } | |||||
| return $type; | |||||
| } | } | ||||
| public function getConduitEditTypes() { | public function getConduitEditTypes() { | ||||
| if (!$this->getUseEdgeTransactions()) { | if (!$this->getUseEdgeTransactions()) { | ||||
| return parent::getConduitEditTypes(); | return parent::getConduitEditTypes(); | ||||
| } | } | ||||
| $transaction_type = $this->getTransactionType(); | $transaction_type = $this->getTransactionType(); | ||||
| Show All 35 Lines | |||||