Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/editfield/PhabricatorEditField.php
Show All 9 Lines | abstract class PhabricatorEditField extends Phobject { | ||||
private $initialValue; | private $initialValue; | ||||
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; | private $editTypeKey; | ||||
private $isRequired; | private $isRequired; | ||||
private $commentActionLabel; | private $commentActionLabel; | ||||
private $commentActionValue; | |||||
private $hasCommentActionValue; | |||||
private $isLocked; | private $isLocked; | ||||
private $isHidden; | private $isHidden; | ||||
private $isPreview; | private $isPreview; | ||||
private $isEditDefaults; | private $isEditDefaults; | ||||
private $isSubmittedForm; | private $isSubmittedForm; | ||||
private $controlError; | private $controlError; | ||||
▲ Show 20 Lines • Show All 170 Lines • ▼ Show 20 Lines | public function setCommentActionLabel($label) { | ||||
$this->commentActionLabel = $label; | $this->commentActionLabel = $label; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getCommentActionLabel() { | public function getCommentActionLabel() { | ||||
return $this->commentActionLabel; | return $this->commentActionLabel; | ||||
} | } | ||||
public function setCommentActionValue($comment_action_value) { | |||||
$this->hasCommentActionValue = true; | |||||
$this->commentActionValue = $comment_action_value; | |||||
return $this; | |||||
} | |||||
public function getCommentActionValue() { | |||||
return $this->commentActionValue; | |||||
} | |||||
protected function newControl() { | protected function newControl() { | ||||
throw new PhutilMethodNotImplementedException(); | throw new PhutilMethodNotImplementedException(); | ||||
} | } | ||||
protected function buildControl() { | protected function buildControl() { | ||||
if ($this->getIsConduitOnly()) { | if ($this->getIsConduitOnly()) { | ||||
return null; | return null; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | foreach ($check as $key) { | ||||
} | } | ||||
$this->value = $this->getValueFromRequest($request, $key); | $this->value = $this->getValueFromRequest($request, $key); | ||||
break; | break; | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
public function readValueFromComment($action) { | public function readValueFromComment($value) { | ||||
$this->value = $this->getValueFromComment(idx($action, 'value')); | $this->value = $this->getValueFromComment($value); | ||||
return $this; | return $this; | ||||
} | } | ||||
protected function getValueFromComment($value) { | protected function getValueFromComment($value) { | ||||
return $value; | return $value; | ||||
} | } | ||||
public function getAllReadValueFromRequestKeys() { | public function getAllReadValueFromRequestKeys() { | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | abstract class PhabricatorEditField extends Phobject { | ||||
protected function getInitialValueFromSubmit(AphrontRequest $request, $key) { | protected function getInitialValueFromSubmit(AphrontRequest $request, $key) { | ||||
return null; | return null; | ||||
} | } | ||||
public function getInitialValue() { | public function getInitialValue() { | ||||
return $this->initialValue; | return $this->initialValue; | ||||
} | } | ||||
public function setInitialValue($initial_value) { | |||||
$this->initialValue = $initial_value; | |||||
return $this; | |||||
} | |||||
public function readValueFromSubmit(AphrontRequest $request) { | public function readValueFromSubmit(AphrontRequest $request) { | ||||
$key = $this->getKey(); | $key = $this->getKey(); | ||||
if ($this->getValueExistsInSubmit($request, $key)) { | if ($this->getValueExistsInSubmit($request, $key)) { | ||||
$value = $this->getValueFromSubmit($request, $key); | $value = $this->getValueFromSubmit($request, $key); | ||||
} else { | } else { | ||||
$value = $this->getDefaultValue(); | $value = $this->getDefaultValue(); | ||||
} | } | ||||
$this->value = $value; | $this->value = $value; | ||||
▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | public function getConduitEditTypes() { | ||||
if ($edit_type === null) { | if ($edit_type === null) { | ||||
return array(); | return array(); | ||||
} | } | ||||
return array($edit_type); | return array($edit_type); | ||||
} | } | ||||
public function getWebEditTypes() { | public function getCommentAction() { | ||||
$label = $this->getCommentActionLabel(); | |||||
if ($label === null) { | |||||
return null; | |||||
} | |||||
$action = $this->newCommentAction(); | |||||
if ($action === null) { | |||||
return null; | |||||
} | |||||
if ($this->hasCommentActionValue) { | |||||
$value = $this->getCommentActionValue(); | |||||
} else { | |||||
$value = $this->getValue(); | |||||
} | |||||
$action | |||||
->setKey($this->getKey()) | |||||
->setLabel($label) | |||||
->setValue($this->getValueForCommentAction($value)); | |||||
return $action; | |||||
} | |||||
protected function newCommentAction() { | |||||
return null; | |||||
} | |||||
protected function getValueForCommentAction($value) { | |||||
return $value; | |||||
} | |||||
public function shouldGenerateTransactionsFromSubmit() { | |||||
if ($this->getIsConduitOnly()) { | if ($this->getIsConduitOnly()) { | ||||
return array(); | return false; | ||||
} | } | ||||
$edit_type = $this->getEditType(); | $edit_type = $this->getEditType(); | ||||
if (!$edit_type) { | |||||
return false; | |||||
} | |||||
if ($edit_type === null) { | return true; | ||||
return array(); | |||||
} | } | ||||
return array($edit_type); | public function shouldReadValueFromRequest() { | ||||
if ($this->getIsConduitOnly()) { | |||||
return false; | |||||
} | } | ||||
public function getCommentEditTypes() { | if ($this->getIsLocked()) { | ||||
return array(); | return false; | ||||
} | |||||
if ($this->getIsHidden()) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
public function shouldReadValueFromSubmit() { | |||||
if ($this->getIsConduitOnly()) { | |||||
return false; | |||||
} | |||||
if ($this->getIsLocked()) { | |||||
return false; | |||||
} | |||||
if ($this->getIsHidden()) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
public function shouldGenerateTransactionsFromComment() { | |||||
if ($this->getIsConduitOnly()) { | |||||
return false; | |||||
} | |||||
if ($this->getIsLocked()) { | |||||
return false; | |||||
} | |||||
if ($this->getIsHidden()) { | |||||
return false; | |||||
} | |||||
return true; | |||||
} | |||||
public function generateTransactions( | |||||
PhabricatorApplicationTransaction $template, | |||||
array $spec) { | |||||
$edit_type = $this->getEditType(); | |||||
if (!$edit_type) { | |||||
throw new Exception( | |||||
pht( | |||||
'EditField (with key "%s", of class "%s") is generating '. | |||||
'transactions, but has no EditType.', | |||||
$this->getKey(), | |||||
get_class($this))); | |||||
} | |||||
return $edit_type->generateTransactions($template, $spec); | |||||
} | } | ||||
} | } |