Add a missing "GROUP BY" to MailQuery when querying for multiple recipients
[phabricator/blender.git] / src / aphront / AphrontController.php
blob4e5df8afbd0fbc418cbd3dd567d5e7cb827fdc48
1 <?php
3 abstract class AphrontController extends Phobject {
5 private $request;
6 private $currentApplication;
7 private $delegatingController;
9 public function setDelegatingController(
10 AphrontController $delegating_controller) {
11 $this->delegatingController = $delegating_controller;
12 return $this;
15 public function getDelegatingController() {
16 return $this->delegatingController;
19 public function willBeginExecution() {
20 return;
23 public function willProcessRequest(array $uri_data) {
24 return;
27 public function handleRequest(AphrontRequest $request) {
28 if (method_exists($this, 'processRequest')) {
29 return $this->processRequest();
32 throw new PhutilMethodNotImplementedException(
33 pht(
34 'Controllers must implement either %s (recommended) '.
35 'or %s (deprecated).',
36 'handleRequest()',
37 'processRequest()'));
40 public function willSendResponse(AphrontResponse $response) {
41 return $response;
44 final public function setRequest(AphrontRequest $request) {
45 $this->request = $request;
46 return $this;
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();
67 if ($application) {
68 $controller->setCurrentApplication($application);
71 return $controller->handleRequest($request);
74 final public function setCurrentApplication(
75 PhabricatorApplication $current_application) {
77 $this->currentApplication = $current_application;
78 return $this;
81 final public function getCurrentApplication() {
82 return $this->currentApplication;
85 public function getDefaultResourceSource() {
86 throw new PhutilMethodNotImplementedException(
87 pht(
88 'A Controller must implement %s before you can invoke %s or %s.',
89 'getDefaultResourceSource()',
90 'requireResource()',
91 'initBehavior()'));
94 public function requireResource($symbol) {
95 $response = CelerityAPI::getStaticResourceResponse();
96 $response->requireResource($symbol, $this->getDefaultResourceSource());
97 return $this;
100 public function initBehavior($name, $config = array()) {
101 Javelin::initBehavior(
102 $name,
103 $config,
104 $this->getDefaultResourceSource());