3 abstract class AphrontController
extends Phobject
{
6 private $currentApplication;
7 private $delegatingController;
9 public function setDelegatingController(
10 AphrontController
$delegating_controller) {
11 $this->delegatingController
= $delegating_controller;
15 public function getDelegatingController() {
16 return $this->delegatingController
;
19 public function willBeginExecution() {
23 public function willProcessRequest(array $uri_data) {
27 public function handleRequest(AphrontRequest
$request) {
28 if (method_exists($this, 'processRequest')) {
29 return $this->processRequest();
32 throw new PhutilMethodNotImplementedException(
34 'Controllers must implement either %s (recommended) '.
35 'or %s (deprecated).',
40 public function willSendResponse(AphrontResponse
$response) {
44 final public function setRequest(AphrontRequest
$request) {
45 $this->request
= $request;
49 final public function getRequest() {
50 if (!$this->request
) {
51 throw new PhutilInvalidStateException('setRequest');
53 return $this->request
;
56 final public function getViewer() {
57 return $this->getRequest()->getViewer();
60 final public function delegateToController(AphrontController
$controller) {
61 $request = $this->getRequest();
63 $controller->setDelegatingController($this);
64 $controller->setRequest($request);
66 $application = $this->getCurrentApplication();
68 $controller->setCurrentApplication($application);
71 return $controller->handleRequest($request);
74 final public function setCurrentApplication(
75 PhabricatorApplication
$current_application) {
77 $this->currentApplication
= $current_application;
81 final public function getCurrentApplication() {
82 return $this->currentApplication
;
85 public function getDefaultResourceSource() {
86 throw new PhutilMethodNotImplementedException(
88 'A Controller must implement %s before you can invoke %s or %s.',
89 'getDefaultResourceSource()',
94 public function requireResource($symbol) {
95 $response = CelerityAPI
::getStaticResourceResponse();
96 $response->requireResource($symbol, $this->getDefaultResourceSource());
100 public function initBehavior($name, $config = array()) {
101 Javelin
::initBehavior(
104 $this->getDefaultResourceSource());