2013-12-03 01:09:07 +01:00
|
|
|
<?php
|
|
|
|
|
2014-05-08 19:08:37 +02:00
|
|
|
final class DrydockBlueprintListController extends DrydockBlueprintController {
|
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();
|
Decouple some aspects of request routing and construction
Summary:
Ref T5702. This is a forward-looking change which provides some very broad API improvements but does not implement them. In particular:
- Controllers no longer require `$request` to construct. This is mostly for T5702, directly, but simplifies things in general. Instead, we call `setRequest()` before using a controller. Only a small number of sites activate controllers, so this is less code overall, and more consistent with most constructors not having any parameters or effects.
- `$request` now offers `getURIData($key, ...)`. This is an alternate way of accessing `$data` which is currently only available on `willProcessRequest(array $data)`. Almost all controllers which implement this method do so in order to read one or two things out of the URI data. Instead, let them just read this data directly when processing the request.
- Introduce `handleRequest(AphrontRequest $request)` and deprecate (very softly) `processRequest()`. The majority of `processRequest()` calls begin `$request = $this->getRequest()`, which is avoided with the more practical signature.
- Provide `getViewer()` on `$request`, and a convenience `getViewer()` on `$controller`. This fixes `$viewer = $request->getUser();` into `$viewer = $request->getViewer();`, and converts the `$request + $viewer` two-liner into a single `$this->getViewer()`.
Test Plan:
- Browsed around in general.
- Hit special controllers (redirect, 404).
- Hit AuditList controller (uses new style).
Reviewers: btrahan
Reviewed By: btrahan
Subscribers: epriestley
Maniphest Tasks: T5702
Differential Revision: https://secure.phabricator.com/D10698
2014-10-17 14:01:40 +02:00
|
|
|
$controller = id(new PhabricatorApplicationSearchController())
|
2013-12-26 21:30:04 +01:00
|
|
|
->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-27 22:15:12 +01:00
|
|
|
public function buildApplicationCrumbs() {
|
2014-01-09 21:19:45 +01:00
|
|
|
$can_create = $this->hasApplicationCapability(
|
2014-07-25 00:20:39 +02:00
|
|
|
DrydockCreateBlueprintsCapability::CAPABILITY);
|
2014-01-09 21:19:45 +01:00
|
|
|
|
2013-12-27 22:15:12 +01:00
|
|
|
$crumbs = parent::buildApplicationCrumbs();
|
|
|
|
$crumbs->addAction(
|
|
|
|
id(new PHUIListItemView())
|
|
|
|
->setName(pht('New Blueprint'))
|
|
|
|
->setHref($this->getApplicationURI('/blueprint/create/'))
|
2014-01-09 21:19:45 +01:00
|
|
|
->setDisabled(!$can_create)
|
|
|
|
->setWorkflow(!$can_create)
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-plus-square'));
|
2013-12-27 22:15:12 +01:00
|
|
|
return $crumbs;
|
|
|
|
}
|
|
|
|
|
2013-12-03 01:09:07 +01:00
|
|
|
}
|