forked from phacility/phabricator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhabricatorOAuthClientListController.php
65 lines (49 loc) · 1.78 KB
/
PhabricatorOAuthClientListController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
final class PhabricatorOAuthClientListController
extends PhabricatorOAuthClientBaseController
implements PhabricatorApplicationSearchResultsControllerInterface {
private $queryKey;
public function shouldAllowPublic() {
return true;
}
public function willProcessRequest(array $data) {
$this->queryKey = idx($data, 'queryKey');
}
public function processRequest() {
$request = $this->getRequest();
$controller = id(new PhabricatorApplicationSearchController($request))
->setQueryKey($this->queryKey)
->setSearchEngine(new PhabricatorOAuthServerClientSearchEngine())
->setNavigation($this->buildSideNavView());
return $this->delegateToController($controller);
}
public function renderResultsList(
array $clients,
PhabricatorSavedQuery $query) {
assert_instances_of($clients, 'PhabricatorOauthServerClient');
$viewer = $this->getRequest()->getUser();
$this->loadHandles(mpull($clients, 'getCreatorPHID'));
$list = id(new PHUIObjectItemListView())
->setUser($viewer);
foreach ($clients as $client) {
$creator = $this->getHandle($client->getCreatorPHID());
$item = id(new PHUIObjectItemView())
->setObjectName(pht('Application %d', $client->getID()))
->setHeader($client->getName())
->setHref($client->getViewURI())
->setObject($client)
->addByline(pht('Creator: %s', $creator->renderLink()));
$list->addItem($item);
}
return $list;
}
public function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
$crumbs->addAction(
id(new PHUIListItemView())
->setHref($this->getApplicationURI('client/create/'))
->setName(pht('Create Application'))
->setIcon('create'));
return $crumbs;
}
}