Path: blob/master/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldBool.php
12242 views
<?php12final class PhabricatorStandardCustomFieldBool3extends PhabricatorStandardCustomField {45public function getFieldType() {6return 'bool';7}89public function buildFieldIndexes() {10$indexes = array();1112$value = $this->getFieldValue();13if (strlen($value)) {14$indexes[] = $this->newNumericIndex((int)$value);15}1617return $indexes;18}1920public function buildOrderIndex() {21return $this->newNumericIndex(0);22}2324public function readValueFromRequest(AphrontRequest $request) {25$this->setFieldValue((bool)$request->getBool($this->getFieldKey()));26}2728public function getValueForStorage() {29$value = $this->getFieldValue();30if ($value !== null) {31return (int)$value;32} else {33return null;34}35}3637public function setValueFromStorage($value) {38if (strlen($value)) {39$value = (bool)$value;40} else {41$value = null;42}43return $this->setFieldValue($value);44}4546public function readApplicationSearchValueFromRequest(47PhabricatorApplicationSearchEngine $engine,48AphrontRequest $request) {4950return $request->getStr($this->getFieldKey());51}5253public function applyApplicationSearchConstraintToQuery(54PhabricatorApplicationSearchEngine $engine,55PhabricatorCursorPagedPolicyAwareQuery $query,56$value) {57if ($value == 'require') {58$query->withApplicationSearchContainsConstraint(59$this->newNumericIndex(null),601);61}62}6364public function appendToApplicationSearchForm(65PhabricatorApplicationSearchEngine $engine,66AphrontFormView $form,67$value) {6869$form->appendChild(70id(new AphrontFormSelectControl())71->setLabel($this->getFieldName())72->setName($this->getFieldKey())73->setValue($value)74->setOptions(75array(76'' => $this->getString('search.default', pht('(Any)')),77'require' => $this->getString('search.require', pht('Require')),78)));79}8081public function renderEditControl(array $handles) {82return id(new AphrontFormCheckboxControl())83->setLabel($this->getFieldName())84->setCaption($this->getCaption())85->addCheckbox(86$this->getFieldKey(),871,88$this->getString('edit.checkbox'),89(bool)$this->getFieldValue());90}9192public function renderPropertyViewValue(array $handles) {93$value = $this->getFieldValue();94if ($value) {95return $this->getString('view.yes', pht('Yes'));96} else {97return null;98}99}100101public function getApplicationTransactionTitle(102PhabricatorApplicationTransaction $xaction) {103$author_phid = $xaction->getAuthorPHID();104$old = $xaction->getOldValue();105$new = $xaction->getNewValue();106107if ($new) {108return pht(109'%s checked %s.',110$xaction->renderHandleLink($author_phid),111$this->getFieldName());112} else {113return pht(114'%s unchecked %s.',115$xaction->renderHandleLink($author_phid),116$this->getFieldName());117}118}119120public function shouldAppearInHerald() {121return true;122}123124public function getHeraldFieldConditions() {125return array(126HeraldAdapter::CONDITION_IS_TRUE,127HeraldAdapter::CONDITION_IS_FALSE,128);129}130131public function getHeraldFieldStandardType() {132return HeraldField::STANDARD_BOOL;133}134135protected function getHTTPParameterType() {136return new AphrontBoolHTTPParameterType();137}138139protected function newConduitSearchParameterType() {140return new ConduitBoolParameterType();141}142143protected function newConduitEditParameterType() {144return new ConduitBoolParameterType();145}146147}148149150