Path: blob/master/src/infrastructure/customfield/editor/PhabricatorCustomFieldEditField.php
12242 views
<?php12final class PhabricatorCustomFieldEditField3extends PhabricatorEditField {45private $customField;6private $httpParameterType;7private $conduitParameterType;8private $bulkParameterType;9private $commentAction;1011public function setCustomField(PhabricatorCustomField $custom_field) {12$this->customField = $custom_field;13return $this;14}1516public function getCustomField() {17return $this->customField;18}1920public function setCustomFieldHTTPParameterType(21AphrontHTTPParameterType $type) {22$this->httpParameterType = $type;23return $this;24}2526public function getCustomFieldHTTPParameterType() {27return $this->httpParameterType;28}2930public function setCustomFieldConduitParameterType(31ConduitParameterType $type) {32$this->conduitParameterType = $type;33return $this;34}3536public function getCustomFieldConduitParameterType() {37return $this->conduitParameterType;38}3940public function setCustomFieldBulkParameterType(41BulkParameterType $type) {42$this->bulkParameterType = $type;43return $this;44}4546public function getCustomFieldBulkParameterType() {47return $this->bulkParameterType;48}4950public function setCustomFieldCommentAction(51PhabricatorEditEngineCommentAction $comment_action) {52$this->commentAction = $comment_action;53return $this;54}5556public function getCustomFieldCommentAction() {57return $this->commentAction;58}5960protected function buildControl() {61if (!$this->getIsFormField()) {62return null;63}6465$field = $this->getCustomField();66$clone = clone $field;6768$value = $this->getValue();69$clone->setValueFromApplicationTransactions($value);7071return $clone->renderEditControl(array());72}7374protected function newEditType() {75return id(new PhabricatorCustomFieldEditType())76->setCustomField($this->getCustomField());77}7879public function getValueForTransaction() {80$value = $this->getValue();81$field = $this->getCustomField();8283// Avoid changing the value of the field itself, since later calls would84// incorrectly reflect the new value.85$clone = clone $field;86$clone->setValueFromApplicationTransactions($value);87return $clone->getNewValueForApplicationTransactions();88}8990protected function getValueForCommentAction($value) {91$field = $this->getCustomField();92$clone = clone $field;93$clone->setValueFromApplicationTransactions($value);9495// TODO: This is somewhat bogus because only StandardCustomFields96// implement a getFieldValue() method -- not all CustomFields. Today,97// only StandardCustomFields can ever actually generate a comment action98// so we never reach this method with other field types.99100return $clone->getFieldValue();101}102103protected function getValueExistsInSubmit(AphrontRequest $request, $key) {104return true;105}106107protected function getValueFromSubmit(AphrontRequest $request, $key) {108$field = $this->getCustomField();109110$clone = clone $field;111112$clone->readValueFromRequest($request);113return $clone->getNewValueForApplicationTransactions();114}115116protected function newConduitEditTypes() {117$field = $this->getCustomField();118119if (!$field->shouldAppearInConduitTransactions()) {120return array();121}122123return parent::newConduitEditTypes();124}125126protected function newHTTPParameterType() {127$type = $this->getCustomFieldHTTPParameterType();128129if ($type) {130return clone $type;131}132133return null;134}135136protected function newCommentAction() {137$action = $this->getCustomFieldCommentAction();138139if ($action) {140return clone $action;141}142143return null;144}145146protected function newConduitParameterType() {147$type = $this->getCustomFieldConduitParameterType();148149if ($type) {150return clone $type;151}152153return null;154}155156protected function newBulkParameterType() {157$type = $this->getCustomFieldBulkParameterType();158159if ($type) {160return clone $type;161}162163return null;164}165166public function getAllReadValueFromRequestKeys() {167$keys = array();168169// NOTE: This piece of complexity is so we can expose a reasonable key in170// the UI ("custom.x") instead of a crufty internal key ("std:app:x").171// Perhaps we can simplify this some day.172173// In the parent, this is just getKey(), but that returns a cumbersome174// key in EditFields. Use the simpler edit type key instead.175$keys[] = $this->getEditTypeKey();176177foreach ($this->getAliases() as $alias) {178$keys[] = $alias;179}180181return $keys;182}183184}185186187