2013-12-03 01:09:07 +01:00
|
|
|
<?php
|
|
|
|
|
2013-12-26 21:30:36 +01:00
|
|
|
final class DrydockBlueprintListController extends DrydockBlueprintController
|
2013-12-26 21:30:04 +01:00
|
|
|
implements PhabricatorApplicationSearchResultsControllerInterface {
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
private $queryKey;
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function willProcessRequest(array $data) {
|
|
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
|
|
}
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function processRequest() {
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$controller = id(new PhabricatorApplicationSearchController($request))
|
|
|
|
->setQueryKey($this->queryKey)
|
|
|
|
->setSearchEngine(new DrydockBlueprintSearchEngine())
|
2013-12-26 21:30:36 +01:00
|
|
|
->setNavigation($this->buildSideNavView());
|
2013-12-03 01:09:07 +01:00
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
return $this->delegateToController($controller);
|
2013-12-03 01:09:07 +01:00
|
|
|
}
|
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
public function renderResultsList(
|
|
|
|
array $blueprints,
|
|
|
|
PhabricatorSavedQuery $query) {
|
2013-12-03 01:09:07 +01:00
|
|
|
assert_instances_of($blueprints, 'DrydockBlueprint');
|
|
|
|
|
2013-12-26 21:30:04 +01:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
2013-12-03 01:09:07 +01:00
|
|
|
$view = new PHUIObjectItemListView();
|
|
|
|
|
|
|
|
foreach ($blueprints as $blueprint) {
|
|
|
|
$item = id(new PHUIObjectItemView())
|
2014-01-09 19:56:34 +01:00
|
|
|
->setHeader($blueprint->getBlueprintName())
|
2013-12-03 01:09:07 +01:00
|
|
|
->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID()))
|
|
|
|
->setObjectName(pht('Blueprint %d', $blueprint->getID()));
|
|
|
|
|
2014-01-09 19:56:34 +01:00
|
|
|
if (!$blueprint->getImplementation()->isEnabled()) {
|
|
|
|
$item->setDisabled(true);
|
2013-12-03 01:09:07 +01:00
|
|
|
}
|
|
|
|
|
2014-01-09 19:56:34 +01:00
|
|
|
$item->addAttribute($blueprint->getImplementation()->getBlueprintName());
|
2013-12-03 01:09:07 +01:00
|
|
|
|
|
|
|
$view->addItem($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-12-27 22:15:12 +01:00
|
|
|
public function buildApplicationCrumbs() {
|
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
$crumbs->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setName(pht('New Blueprint'))
|
|
|
|
->setHref($this->getApplicationURI('/blueprint/create/'))
|
|
|
|
->setIcon('create'));
|
|
|
|
return $crumbs;
|
|
|
|
}
|
|
|
|
|
2013-12-03 01:09:07 +01:00
|
|
|
}
|