Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorEditField.php
<?php | <?php | ||||
abstract class PhabricatorEditField extends Phobject { | abstract class PhabricatorEditField extends Phobject { | ||||
private $key; | private $key; | ||||
private $viewer; | private $viewer; | ||||
private $label; | private $label; | ||||
private $aliases = array(); | private $aliases = array(); | ||||
private $value; | private $value; | ||||
private $hasValue = false; | private $hasValue = false; | ||||
private $object; | private $object; | ||||
private $transactionType; | private $transactionType; | ||||
private $metadata = array(); | private $metadata = array(); | ||||
private $description; | private $description; | ||||
private $editTypeKey; | |||||
public function setKey($key) { | public function setKey($key) { | ||||
$this->key = $key; | $this->key = $key; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getKey() { | public function getKey() { | ||||
return $this->key; | return $this->key; | ||||
▲ Show 20 Lines • Show All 195 Lines • ▼ Show 20 Lines | protected function getListFromRequest( | ||||
return $list; | return $list; | ||||
} | } | ||||
public function getHTTPParameterType() { | public function getHTTPParameterType() { | ||||
return 'string'; | return 'string'; | ||||
} | } | ||||
public function setEditTypeKey($edit_type_key) { | |||||
$this->editTypeKey = $edit_type_key; | |||||
return $this; | |||||
} | |||||
public function getEditTypeKey() { | |||||
if ($this->editTypeKey === null) { | |||||
return $this->getKey(); | |||||
} | |||||
return $this->editTypeKey; | |||||
} | |||||
public function getEditTransactionTypes() { | |||||
$transaction_type = $this->getTransactionType(); | |||||
$type_key = $this->getEditTypeKey(); | |||||
// TODO: This is a pretty big pile of hard-coded hacks for now. | |||||
$edge_types = array( | |||||
PhabricatorTransactions::TYPE_EDGE => array( | |||||
'+' => pht('Add projects.'), | |||||
'-' => pht('Remove projects.'), | |||||
'=' => pht('Set associated projects, overwriting current value.'), | |||||
), | |||||
PhabricatorTransactions::TYPE_SUBSCRIBERS => array( | |||||
'+' => pht('Add subscribers.'), | |||||
'-' => pht('Remove subscribers.'), | |||||
'=' => pht('Set subscribers, overwriting current value.'), | |||||
), | |||||
); | |||||
if (isset($edge_types[$transaction_type])) { | |||||
$base = id(new PhabricatorEdgeEditType()) | |||||
->setTransactionType($transaction_type) | |||||
->setMetadata($this->metadata); | |||||
$strings = $edge_types[$transaction_type]; | |||||
$add = id(clone $base) | |||||
->setEditType($type_key.'.add') | |||||
->setEdgeOperation('+') | |||||
->setDescription($strings['+']) | |||||
->setValueDescription(pht('List of PHIDs to add.')); | |||||
$rem = id(clone $base) | |||||
->setEditType($type_key.'.remove') | |||||
->setEdgeOperation('-') | |||||
->setDescription($strings['-']) | |||||
->setValueDescription(pht('List of PHIDs to remove.')); | |||||
$set = id(clone $base) | |||||
->setEditType($type_key.'.set') | |||||
->setEdgeOperation('=') | |||||
->setDescription($strings['=']) | |||||
->setValueDescription(pht('List of PHIDs to set.')); | |||||
return array( | |||||
$add, | |||||
$rem, | |||||
$set, | |||||
); | |||||
} | |||||
return array( | |||||
id(new PhabricatorSimpleEditType()) | |||||
->setEditType($type_key) | |||||
->setTransactionType($transaction_type) | |||||
->setValueType($this->getHTTPParameterType()) | |||||
->setDescription($this->getDescription()) | |||||
->setMetadata($this->metadata), | |||||
); | |||||
} | |||||
} | } |