Changeset View
Changeset View
Standalone View
Standalone View
src/applications/project/state/PhabricatorWorkboardViewState.php
| <?php | <?php | ||||
| final class PhabricatorWorkboardViewState | final class PhabricatorWorkboardViewState | ||||
| extends Phobject { | extends Phobject { | ||||
| private $viewer; | |||||
| private $project; | private $project; | ||||
| private $requestState = array(); | private $requestState = array(); | ||||
| private $savedQuery; | |||||
| private $searchEngine; | |||||
| public function setProject(PhabricatorProject $project) { | public function setProject(PhabricatorProject $project) { | ||||
| $this->project = $project; | $this->project = $project; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getProject() { | public function getProject() { | ||||
| return $this->project; | return $this->project; | ||||
| Show All 19 Lines | public function readFromRequest(AphrontRequest $request) { | ||||
| if ($request->getExists('filter')) { | if ($request->getExists('filter')) { | ||||
| $this->requestState['filter'] = $request->getStr('filter'); | $this->requestState['filter'] = $request->getStr('filter'); | ||||
| } | } | ||||
| if (strlen($request->getURIData('queryKey'))) { | if (strlen($request->getURIData('queryKey'))) { | ||||
| $this->requestState['filter'] = $request->getURIData('queryKey'); | $this->requestState['filter'] = $request->getURIData('queryKey'); | ||||
| } | } | ||||
| $this->viewer = $request->getViewer(); | |||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function getViewer() { | |||||
| return $this->viewer; | |||||
| } | |||||
| public function getSavedQuery() { | |||||
| if ($this->savedQuery === null) { | |||||
| $this->savedQuery = $this->newSavedQuery(); | |||||
| } | |||||
| return $this->savedQuery; | |||||
| } | |||||
| private function newSavedQuery() { | |||||
| $search_engine = $this->getSearchEngine(); | |||||
| $query_key = $this->getQueryKey(); | |||||
| $viewer = $this->getViewer(); | |||||
| if ($search_engine->isBuiltinQuery($query_key)) { | |||||
| $saved_query = $search_engine->buildSavedQueryFromBuiltin($query_key); | |||||
| } else { | |||||
| $saved_query = id(new PhabricatorSavedQueryQuery()) | |||||
| ->setViewer($viewer) | |||||
| ->withQueryKeys(array($query_key)) | |||||
| ->executeOne(); | |||||
| } | |||||
| return $saved_query; | |||||
| } | |||||
| public function getSearchEngine() { | |||||
| if ($this->searchEngine === null) { | |||||
| $this->searchEngine = $this->newSearchEngine(); | |||||
| } | |||||
| return $this->searchEngine; | |||||
| } | |||||
| private function newSearchEngine() { | |||||
| $viewer = $this->getViewer(); | |||||
| // TODO: This URI is not fully state-preserving, because "SearchEngine" | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
| // does not preserve URI parameters when constructing some URIs at time of | |||||
| // writing. | |||||
epriestleyAuthorUnsubmitted Done Inline Actions(This isn't ideal from a correctness standpoint, but doesn't appear to actually cause any problematic behavior.) epriestley: (This isn't ideal from a correctness standpoint, but doesn't appear to actually cause any… | |||||
| $board_uri = $this->getProject()->getWorkboardURI(); | |||||
| return id(new ManiphestTaskSearchEngine()) | |||||
| ->setViewer($viewer) | |||||
| ->setBaseURI($board_uri) | |||||
| ->setIsBoardView(true); | |||||
| } | |||||
| public function newWorkboardURI($path = null) { | public function newWorkboardURI($path = null) { | ||||
| $project = $this->getProject(); | $project = $this->getProject(); | ||||
| $uri = urisprintf('%s%s', $project->getWorkboardURI(), $path); | $uri = urisprintf('%s%s', $project->getWorkboardURI(), $path); | ||||
| return $this->newURI($uri); | return $this->newURI($uri); | ||||
| } | } | ||||
| public function newURI($path, $force = false) { | public function newURI($path, $force = false) { | ||||
| $project = $this->getProject(); | $project = $this->getProject(); | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | public function getQueryKey() { | ||||
| $request_query = idx($this->requestState, 'filter'); | $request_query = idx($this->requestState, 'filter'); | ||||
| if (strlen($request_query)) { | if (strlen($request_query)) { | ||||
| return $request_query; | return $request_query; | ||||
| } | } | ||||
| return $this->getDefaultQueryKey(); | return $this->getDefaultQueryKey(); | ||||
| } | } | ||||
| public function setQueryKey($query_key) { | |||||
| $this->requestState['filter'] = $query_key; | |||||
| return $this; | |||||
| } | |||||
| private function isValidOrder($order) { | private function isValidOrder($order) { | ||||
| $map = PhabricatorProjectColumnOrder::getEnabledOrders(); | $map = PhabricatorProjectColumnOrder::getEnabledOrders(); | ||||
| return isset($map[$order]); | return isset($map[$order]); | ||||
| } | } | ||||
| private function getDefaultOrder() { | private function getDefaultOrder() { | ||||
| $project = $this->getProject(); | $project = $this->getProject(); | ||||
| Show All 26 Lines | |||||
This comment has a TODO.