1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-02 19:52:44 +01:00
phorge-phorge/src/aphront/AphrontController.php

87 lines
2 KiB
PHP
Raw Normal View History

<?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;
}
2011-01-26 22:21:12 +01:00
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;
}
2011-02-28 04:47:22 +01:00
final public function delegateToController(AphrontController $controller) {
$controller->setDelegatingController($this);
$application = $this->getCurrentApplication();
if ($application) {
$controller->setCurrentApplication($application);
}
2011-02-28 04:47:22 +01:00
return $controller->processRequest();
}
final public function setCurrentApplication(
PhabricatorApplication $current_application) {
$this->currentApplication = $current_application;
return $this;
}
final public function getCurrentApplication() {
return $this->currentApplication;
}
public function getDefaultResourceSource() {
throw new Exception(
pht(
'A Controller must implement getDefaultResourceSource() before you '.
'can invoke requireResource() or initBehavior().'));
}
public function requireResource($symbol) {
$response = CelerityAPI::getStaticResourceResponse();
$response->requireResource($symbol, $this->getDefaultResourceSource());
return $this;
}
public function initBehavior($name, $config = array()) {
Javelin::initBehavior(
$name,
$config,
$this->getDefaultResourceSource());
}
}