Skip to content

Commit e6aff10

Browse files
author
epriestley
committedMay 9, 2014
Move even more rendering into SearchEngine
Summary: Ref T4986. I think this is the last of the easy ones, there are about 10 not-quite-so-trivial ones left. Test Plan: - Viewed app results. - Created panels. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T4986 Differential Revision: https://secure.phabricator.com/D9025
1 parent 352d9f6 commit e6aff10

7 files changed

+103
-97
lines changed
 

‎src/__phutil_library_map__.php

+2-10
Original file line numberDiff line numberDiff line change
@@ -4895,11 +4895,7 @@
48954895
'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
48964896
'PhabricatorSearchBaseController' => 'PhabricatorController',
48974897
'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions',
4898-
'PhabricatorSearchController' =>
4899-
array(
4900-
0 => 'PhabricatorSearchBaseController',
4901-
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
4902-
),
4898+
'PhabricatorSearchController' => 'PhabricatorSearchBaseController',
49034899
'PhabricatorSearchDAO' => 'PhabricatorLiskDAO',
49044900
'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController',
49054901
'PhabricatorSearchDocument' => 'PhabricatorSearchDAO',
@@ -5524,11 +5520,7 @@
55245520
'ReleephProductEditController' => 'ReleephProductController',
55255521
'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
55265522
'ReleephProductHistoryController' => 'ReleephProductController',
5527-
'ReleephProductListController' =>
5528-
array(
5529-
0 => 'ReleephController',
5530-
1 => 'PhabricatorApplicationSearchResultsControllerInterface',
5531-
),
5523+
'ReleephProductListController' => 'ReleephController',
55325524
'ReleephProductQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
55335525
'ReleephProductSearchEngine' => 'PhabricatorApplicationSearchEngine',
55345526
'ReleephProductTransaction' => 'PhabricatorApplicationTransaction',

‎src/applications/diffusion/controller/DiffusionPushLogListController.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

3-
final class DiffusionPushLogListController extends DiffusionPushLogController {
3+
final class DiffusionPushLogListController extends DiffusionPushLogController
4+
implements PhabricatorApplicationSearchResultsControllerInterface {
45

56
private $queryKey;
67

‎src/applications/releeph/controller/product/ReleephProductListController.php

+1-43
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

3-
final class ReleephProductListController extends ReleephController
4-
implements PhabricatorApplicationSearchResultsControllerInterface {
3+
final class ReleephProductListController extends ReleephController {
54

65
private $queryKey;
76

@@ -23,47 +22,6 @@ public function processRequest() {
2322
return $this->delegateToController($controller);
2423
}
2524

26-
public function renderResultsList(
27-
array $products,
28-
PhabricatorSavedQuery $query) {
29-
assert_instances_of($products, 'ReleephProject');
30-
$viewer = $this->getRequest()->getUser();
31-
32-
$list = id(new PHUIObjectItemListView())
33-
->setUser($viewer);
34-
35-
foreach ($products as $product) {
36-
$id = $product->getID();
37-
38-
$item = id(new PHUIObjectItemView())
39-
->setHeader($product->getName())
40-
->setHref($this->getApplicationURI("product/{$id}/"));
41-
42-
if (!$product->getIsActive()) {
43-
$item->setDisabled(true);
44-
$item->addIcon('none', pht('Inactive'));
45-
}
46-
47-
$repo = $product->getRepository();
48-
$item->addAttribute(
49-
phutil_tag(
50-
'a',
51-
array(
52-
'href' => '/diffusion/'.$repo->getCallsign().'/',
53-
),
54-
'r'.$repo->getCallsign()));
55-
56-
$arc = $product->getArcanistProject();
57-
if ($arc) {
58-
$item->addAttribute($arc->getName());
59-
}
60-
61-
$list->addItem($item);
62-
}
63-
64-
return $list;
65-
}
66-
6725
public function buildApplicationCrumbs() {
6826
$crumbs = parent::buildApplicationCrumbs();
6927

‎src/applications/releeph/query/ReleephProductSearchEngine.php

+48
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
final class ReleephProductSearchEngine
44
extends PhabricatorApplicationSearchEngine {
55

6+
public function getApplicationClassName() {
7+
return 'PhabricatorApplicationReleeph';
8+
}
9+
610
public function buildSavedQueryFromRequest(AphrontRequest $request) {
711
$saved = new PhabricatorSavedQuery();
812

@@ -83,4 +87,48 @@ private function getActiveValues() {
8387
);
8488
}
8589

90+
protected function renderResultList(
91+
array $products,
92+
PhabricatorSavedQuery $query,
93+
array $handles) {
94+
95+
assert_instances_of($products, 'ReleephProject');
96+
$viewer = $this->requireViewer();
97+
98+
$list = id(new PHUIObjectItemListView())
99+
->setUser($viewer);
100+
101+
foreach ($products as $product) {
102+
$id = $product->getID();
103+
104+
$item = id(new PHUIObjectItemView())
105+
->setHeader($product->getName())
106+
->setHref($this->getApplicationURI("product/{$id}/"));
107+
108+
if (!$product->getIsActive()) {
109+
$item->setDisabled(true);
110+
$item->addIcon('none', pht('Inactive'));
111+
}
112+
113+
$repo = $product->getRepository();
114+
$item->addAttribute(
115+
phutil_tag(
116+
'a',
117+
array(
118+
'href' => '/diffusion/'.$repo->getCallsign().'/',
119+
),
120+
'r'.$repo->getCallsign()));
121+
122+
$arc = $product->getArcanistProject();
123+
if ($arc) {
124+
$item->addAttribute($arc->getName());
125+
}
126+
127+
$list->addItem($item);
128+
}
129+
130+
return $list;
131+
}
132+
133+
86134
}

‎src/applications/repository/query/PhabricatorRepositoryPushLogSearchEngine.php

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
final class PhabricatorRepositoryPushLogSearchEngine
44
extends PhabricatorApplicationSearchEngine {
55

6+
public function getApplicationClassName() {
7+
return 'PhabricatorApplicationDiffusion';
8+
}
9+
610
public function buildSavedQueryFromRequest(AphrontRequest $request) {
711
$saved = new PhabricatorSavedQuery();
812

‎src/applications/search/controller/PhabricatorSearchController.php

+1-43
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22

33
final class PhabricatorSearchController
4-
extends PhabricatorSearchBaseController
5-
implements PhabricatorApplicationSearchResultsControllerInterface {
4+
extends PhabricatorSearchBaseController {
65

76
private $queryKey;
87

@@ -96,45 +95,4 @@ public function buildSideNavView($for_app = false) {
9695
return $nav;
9796
}
9897

99-
public function renderResultsList(
100-
array $results,
101-
PhabricatorSavedQuery $query) {
102-
103-
$viewer = $this->getRequest()->getUser();
104-
105-
if ($results) {
106-
$objects = id(new PhabricatorObjectQuery())
107-
->setViewer($viewer)
108-
->withPHIDs(mpull($results, 'getPHID'))
109-
->execute();
110-
111-
$output = array();
112-
foreach ($results as $phid => $handle) {
113-
$view = id(new PhabricatorSearchResultView())
114-
->setHandle($handle)
115-
->setQuery($query)
116-
->setObject(idx($objects, $phid));
117-
$output[] = $view->render();
118-
}
119-
120-
$results = phutil_tag_div(
121-
'phabricator-search-result-list',
122-
$output);
123-
} else {
124-
$results = phutil_tag_div(
125-
'phabricator-search-result-list',
126-
phutil_tag(
127-
'p',
128-
array('class' => 'phabricator-search-no-results'),
129-
pht('No search results.')));
130-
}
131-
132-
return id(new PHUIBoxView())
133-
->addMargin(PHUI::MARGIN_LARGE)
134-
->addPadding(PHUI::PADDING_LARGE)
135-
->setBorder(true)
136-
->appendChild($results)
137-
->addClass('phabricator-search-result-box');
138-
}
139-
14098
}

‎src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php

+45
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
final class PhabricatorSearchApplicationSearchEngine
44
extends PhabricatorApplicationSearchEngine {
55

6+
public function getApplicationClassName() {
7+
return 'PhabricatorApplicationSearch';
8+
}
9+
610
public function buildSavedQueryFromRequest(AphrontRequest $request) {
711
$saved = new PhabricatorSavedQuery();
812

@@ -233,5 +237,46 @@ public function shouldUseOffsetPaging() {
233237
return true;
234238
}
235239

240+
protected function renderResultList(
241+
array $results,
242+
PhabricatorSavedQuery $query,
243+
array $handles) {
244+
245+
$viewer = $this->requireViewer();
246+
247+
if ($results) {
248+
$objects = id(new PhabricatorObjectQuery())
249+
->setViewer($viewer)
250+
->withPHIDs(mpull($results, 'getPHID'))
251+
->execute();
252+
253+
$output = array();
254+
foreach ($results as $phid => $handle) {
255+
$view = id(new PhabricatorSearchResultView())
256+
->setHandle($handle)
257+
->setQuery($query)
258+
->setObject(idx($objects, $phid));
259+
$output[] = $view->render();
260+
}
261+
262+
$results = phutil_tag_div(
263+
'phabricator-search-result-list',
264+
$output);
265+
} else {
266+
$results = phutil_tag_div(
267+
'phabricator-search-result-list',
268+
phutil_tag(
269+
'p',
270+
array('class' => 'phabricator-search-no-results'),
271+
pht('No search results.')));
272+
}
273+
274+
return id(new PHUIBoxView())
275+
->addMargin(PHUI::MARGIN_LARGE)
276+
->addPadding(PHUI::PADDING_LARGE)
277+
->setBorder(true)
278+
->appendChild($results)
279+
->addClass('phabricator-search-result-box');
280+
}
236281

237282
}

0 commit comments

Comments
 (0)
Failed to load comments.