2014-10-17 05:04:24 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class AlmanacInterfaceEditController
|
|
|
|
extends AlmanacDeviceController {
|
|
|
|
|
|
|
|
public function handleRequest(AphrontRequest $request) {
|
2018-04-10 06:09:51 -07:00
|
|
|
$viewer = $this->getViewer();
|
2014-10-17 05:04:24 -07:00
|
|
|
|
2018-04-10 06:09:51 -07:00
|
|
|
$engine = id(new AlmanacInterfaceEditEngine())
|
|
|
|
->setController($this);
|
2014-10-17 05:04:24 -07:00
|
|
|
|
2018-04-10 06:09:51 -07:00
|
|
|
$id = $request->getURIData('id');
|
|
|
|
if (!$id) {
|
2014-10-17 05:04:24 -07:00
|
|
|
$device = id(new AlmanacDeviceQuery())
|
|
|
|
->setViewer($viewer)
|
2018-04-10 06:09:51 -07:00
|
|
|
->withIDs(array($request->getInt('deviceID')))
|
2014-10-17 05:04:24 -07:00
|
|
|
->requireCapabilities(
|
|
|
|
array(
|
|
|
|
PhabricatorPolicyCapability::CAN_VIEW,
|
|
|
|
PhabricatorPolicyCapability::CAN_EDIT,
|
|
|
|
))
|
|
|
|
->executeOne();
|
|
|
|
if (!$device) {
|
|
|
|
return new Aphront404Response();
|
|
|
|
}
|
|
|
|
|
2018-04-10 06:09:51 -07:00
|
|
|
$engine
|
|
|
|
->addContextParameter('deviceID', $device->getID())
|
|
|
|
->setDevice($device);
|
2014-10-17 05:04:24 -07:00
|
|
|
}
|
|
|
|
|
2018-04-10 06:09:51 -07:00
|
|
|
return $engine->buildResponse();
|
2014-10-17 05:04:24 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|