Differential D14699 Diff 35551 src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/customfield/standard/PhabricatorStandardCustomField.php
| Show All 9 Lines | abstract class PhabricatorStandardCustomField | ||||
| private $fieldDescription; | private $fieldDescription; | ||||
| private $fieldConfig; | private $fieldConfig; | ||||
| private $applicationField; | private $applicationField; | ||||
| private $strings = array(); | private $strings = array(); | ||||
| private $caption; | private $caption; | ||||
| private $fieldError; | private $fieldError; | ||||
| private $required; | private $required; | ||||
| private $default; | private $default; | ||||
| private $isCopyable; | |||||
| abstract public function getFieldType(); | abstract public function getFieldType(); | ||||
| public static function buildStandardFields( | public static function buildStandardFields( | ||||
| PhabricatorCustomField $template, | PhabricatorCustomField $template, | ||||
| array $config) { | array $config) { | ||||
| $types = id(new PhutilClassMapQuery()) | $types = id(new PhutilClassMapQuery()) | ||||
| ▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | foreach ($config as $key => $value) { | ||||
| if ($value) { | if ($value) { | ||||
| $this->setRequired($value); | $this->setRequired($value); | ||||
| $this->setFieldError(true); | $this->setFieldError(true); | ||||
| } | } | ||||
| break; | break; | ||||
| case 'default': | case 'default': | ||||
| $this->setFieldValue($value); | $this->setFieldValue($value); | ||||
| break; | break; | ||||
| case 'copy': | |||||
| $this->setIsCopyable($value); | |||||
| break; | |||||
| case 'type': | case 'type': | ||||
| // We set this earlier on. | // We set this earlier on. | ||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| $this->fieldConfig = $config; | $this->fieldConfig = $config; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | public function setStrings(array $strings) { | ||||
| $this->strings = $strings; | $this->strings = $strings; | ||||
| return; | return; | ||||
| } | } | ||||
| public function getString($key, $default = null) { | public function getString($key, $default = null) { | ||||
| return idx($this->strings, $key, $default); | return idx($this->strings, $key, $default); | ||||
| } | } | ||||
| public function setIsCopyable($is_copyable) { | |||||
| $this->isCopyable = $is_copyable; | |||||
| return $this; | |||||
| } | |||||
| public function getIsCopyable() { | |||||
| return $this->isCopyable; | |||||
| } | |||||
| public function shouldUseStorage() { | public function shouldUseStorage() { | ||||
| try { | try { | ||||
| $object = $this->newStorageObject(); | $object = $this->newStorageObject(); | ||||
| return true; | return true; | ||||
| } catch (PhabricatorCustomFieldImplementationIncompleteException $ex) { | } catch (PhabricatorCustomFieldImplementationIncompleteException $ex) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 229 Lines • ▼ Show 20 Lines | if (strlen($field_value)) { | ||||
| $document->addField($field_key, $field_value); | $document->addField($field_key, $field_value); | ||||
| } | } | ||||
| } | } | ||||
| protected function newStandardEditField() { | protected function newStandardEditField() { | ||||
| $short = 'custom.'.$this->getRawStandardFieldKey(); | $short = 'custom.'.$this->getRawStandardFieldKey(); | ||||
| return parent::newStandardEditField() | return parent::newStandardEditField() | ||||
| ->setEditTypeKey($short); | ->setEditTypeKey($short) | ||||
| ->setIsCopyable($this->getIsCopyable()); | |||||
| } | } | ||||
| public function shouldAppearInConduitTransactions() { | public function shouldAppearInConduitTransactions() { | ||||
| return true; | return true; | ||||
| } | } | ||||
| } | } | ||||