Changeset View
Changeset View
Standalone View
Standalone View
src/view/form/control/AphrontFormTokenizerControl.php
| <?php | <?php | ||||
| final class AphrontFormTokenizerControl extends AphrontFormControl { | final class AphrontFormTokenizerControl extends AphrontFormControl { | ||||
| private $datasource; | private $datasource; | ||||
| private $disableBehavior; | private $disableBehavior; | ||||
| private $limit; | private $limit; | ||||
| private $placeholder; | private $placeholder; | ||||
| private $handles; | private $handles; | ||||
| private $originalValue; | |||||
| public function setDatasource(PhabricatorTypeaheadDatasource $datasource) { | public function setDatasource(PhabricatorTypeaheadDatasource $datasource) { | ||||
| $this->datasource = $datasource; | $this->datasource = $datasource; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setDisableBehavior($disable) { | public function setDisableBehavior($disable) { | ||||
| $this->disableBehavior = $disable; | $this->disableBehavior = $disable; | ||||
| Show All 9 Lines | public function setLimit($limit) { | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setPlaceholder($placeholder) { | public function setPlaceholder($placeholder) { | ||||
| $this->placeholder = $placeholder; | $this->placeholder = $placeholder; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setOriginalValue(array $original_value) { | |||||
| $this->originalValue = $original_value; | |||||
| return $this; | |||||
| } | |||||
| public function getOriginalValue() { | |||||
| return $this->originalValue; | |||||
| } | |||||
| public function willRender() { | public function willRender() { | ||||
| // Load the handles now so we'll get a bulk load later on when we actually | // Load the handles now so we'll get a bulk load later on when we actually | ||||
| // render them. | // render them. | ||||
| $this->loadHandles(); | $this->loadHandles(); | ||||
| } | } | ||||
| protected function renderInput() { | protected function renderInput() { | ||||
| $name = $this->getName(); | $name = $this->getName(); | ||||
| Show All 21 Lines | protected function renderInput() { | ||||
| $values = nonempty($this->getValue(), array()); | $values = nonempty($this->getValue(), array()); | ||||
| $tokens = $datasource->renderTokens($values); | $tokens = $datasource->renderTokens($values); | ||||
| foreach ($tokens as $token) { | foreach ($tokens as $token) { | ||||
| $token->setInputName($this->getName()); | $token->setInputName($this->getName()); | ||||
| } | } | ||||
| $template = new AphrontTokenizerTemplateView(); | $template = id(new AphrontTokenizerTemplateView()) | ||||
| $template->setName($name); | ->setName($name) | ||||
| $template->setID($id); | ->setID($id) | ||||
| $template->setValue($tokens); | ->setValue($tokens); | ||||
| $original_value = $this->getOriginalValue(); | |||||
| if ($original_value !== null) { | |||||
| $template->setOriginalValue($original_value); | |||||
| } | |||||
| $username = null; | $username = null; | ||||
| if ($this->user) { | if ($this->user) { | ||||
| $username = $this->user->getUsername(); | $username = $this->user->getUsername(); | ||||
| } | } | ||||
| $datasource_uri = $datasource->getDatasourceURI(); | $datasource_uri = $datasource->getDatasourceURI(); | ||||
| $browse_uri = $datasource->getBrowseURI(); | $browse_uri = $datasource->getBrowseURI(); | ||||
| ▲ Show 20 Lines • Show All 51 Lines • Show Last 20 Lines | |||||