1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 17:22:42 +01:00
phorge-phorge/src/aphront/AphrontController.php
epriestley 5d94a8a338 Use delegation to generalize application search controllers
Summary:
Ref T2625. Lifts almost all of the search logic out of Paste controllers and into Search.

This uses controller delegation for generalization. We use this in a few places, but don't use it very much yet. I think it's pretty reasonable as-is, but I might be able to make even more stuff free.

There are some slightly rough edges around routes, still, but I want to hit Phame and Differential (which both have multiple application search engines) before trying to generalize that.

Test Plan: Executed, browsed and managed Paste searches.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6073
2013-05-30 14:09:02 -07:00

67 lines
1.4 KiB
PHP

<?php
/**
* @group aphront
*/
abstract class AphrontController extends Phobject {
private $request;
private $currentApplication;
private $delegatingController;
public function setDelegatingController(
AphrontController $delegating_controller) {
$this->delegatingController = $delegating_controller;
return $this;
}
public function getDelegatingController() {
return $this->delegatingController;
}
public function willBeginExecution() {
return;
}
public function willProcessRequest(array $uri_data) {
return;
}
public function didProcessRequest($response) {
return $response;
}
abstract public function processRequest();
final public function __construct(AphrontRequest $request) {
$this->request = $request;
}
final public function getRequest() {
return $this->request;
}
final public function delegateToController(AphrontController $controller) {
$controller->setDelegatingController($this);
$application = $this->getCurrentApplication();
if ($application) {
$controller->setCurrentApplication($application);
}
return $controller->processRequest();
}
final public function setCurrentApplication(
PhabricatorApplication $current_application) {
$this->currentApplication = $current_application;
return $this;
}
final public function getCurrentApplication() {
return $this->currentApplication;
}
}