Path: blob/master/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldTokenizer.php
12242 views
<?php12abstract class PhabricatorStandardCustomFieldTokenizer3extends PhabricatorStandardCustomFieldPHIDs {45abstract public function getDatasource();67public function renderEditControl(array $handles) {8$value = $this->getFieldValue();910$control = id(new AphrontFormTokenizerControl())11->setUser($this->getViewer())12->setLabel($this->getFieldName())13->setName($this->getFieldKey())14->setDatasource($this->getDatasource())15->setCaption($this->getCaption())16->setError($this->getFieldError())17->setValue(nonempty($value, array()));1819$limit = $this->getFieldConfigValue('limit');20if ($limit) {21$control->setLimit($limit);22}2324return $control;25}2627public function appendToApplicationSearchForm(28PhabricatorApplicationSearchEngine $engine,29AphrontFormView $form,30$value) {3132$control = id(new AphrontFormTokenizerControl())33->setLabel($this->getFieldName())34->setName($this->getFieldKey())35->setDatasource($this->newApplicationSearchDatasource())36->setValue(nonempty($value, array()));3738$form->appendControl($control);39}4041public function applyApplicationSearchConstraintToQuery(42PhabricatorApplicationSearchEngine $engine,43PhabricatorCursorPagedPolicyAwareQuery $query,44$value) {45if ($value) {4647$datasource = $this->newApplicationSearchDatasource()48->setViewer($this->getViewer());49$value = $datasource->evaluateTokens($value);5051$query->withApplicationSearchContainsConstraint(52$this->newStringIndex(null),53$value);54}55}5657public function getHeraldFieldValueType($condition) {58return id(new HeraldTokenizerFieldValue())59->setKey('custom.'.$this->getFieldKey())60->setDatasource($this->getDatasource());61}6263public function getHeraldFieldStandardType() {64return HeraldField::STANDARD_PHID_LIST;65}6667public function getHeraldDatasource() {68return $this->getDatasource();69}7071protected function getHTTPParameterType() {72return new AphrontPHIDListHTTPParameterType();73}7475protected function newConduitSearchParameterType() {76return new ConduitPHIDListParameterType();77}7879protected function newConduitEditParameterType() {80return new ConduitPHIDListParameterType();81}8283protected function newBulkParameterType() {84$datasource = $this->getDatasource();8586$limit = $this->getFieldConfigValue('limit');87if ($limit) {88$datasource->setLimit($limit);89}9091return id(new BulkTokenizerParameterType())92->setDatasource($datasource);93}9495public function shouldAppearInHeraldActions() {96return true;97}9899public function getHeraldActionName() {100return pht('Set "%s" to', $this->getFieldName());101}102103public function getHeraldActionDescription($value) {104$list = $this->renderHeraldHandleList($value);105return pht('Set "%s" to: %s.', $this->getFieldName(), $list);106}107108public function getHeraldActionEffectDescription($value) {109return $this->renderHeraldHandleList($value);110}111112public function getHeraldActionStandardType() {113return HeraldAction::STANDARD_PHID_LIST;114}115116public function getHeraldActionDatasource() {117$datasource = $this->getDatasource();118119$limit = $this->getFieldConfigValue('limit');120if ($limit) {121$datasource->setLimit($limit);122}123124return $datasource;125}126127private function renderHeraldHandleList($value) {128if (!is_array($value)) {129return pht('(Invalid List)');130} else {131return $this->getViewer()132->renderHandleList($value)133->setAsInline(true)134->render();135}136}137138protected function newApplicationSearchDatasource() {139$datasource = $this->getDatasource();140141return id(new PhabricatorCustomFieldApplicationSearchDatasource())142->setDatasource($datasource);143}144145protected function newCommentAction() {146$viewer = $this->getViewer();147148$datasource = $this->getDatasource()149->setViewer($viewer);150151$action = id(new PhabricatorEditEngineTokenizerCommentAction())152->setDatasource($datasource);153154$limit = $this->getFieldConfigValue('limit');155if ($limit) {156$action->setLimit($limit);157}158159$value = $this->getFieldValue();160if ($value !== null) {161$action->setInitialValue($value);162}163164return $action;165}166167}168169170