-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathHttpFrontController.class.php
More file actions
80 lines (66 loc) · 1.8 KB
/
HttpFrontController.class.php
File metadata and controls
80 lines (66 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/***************************************************************************
* Copyright (C) 2013 by Nikita V. Konstantinov *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation; either version 3 of the *
* License, or (at your option) any later version. *
* *
***************************************************************************/
/**
* @ingroup Flow
**/
abstract class HttpFrontController
{
/**
* @var HttpRequest
*/
protected $request = null;
/**
* @var Controller
*/
protected $controller = null;
/**
* @var ModelAndView
*/
protected $response = null;
/**
* @var ViewResolver
*/
protected $resolver = null;
/**
* @return Controller
*/
abstract protected function getController();
public function __construct(ViewResolver $resolver)
{
$this->resolver = $resolver;
}
public function handleRequest(HttpRequest $request)
{
$this->request = $request;
$this->response = $this->getController()->handleRequest($request);
$this->render()->terminateRequest();
return $this;
}
protected function render()
{
if (is_string($this->response->getView())) {
$this->response->setView(
$this->resolver->resolveViewName(
$this->response->getView()
)
);
}
$this->response->render();
return $this;
}
protected function terminateRequest()
{
if (function_exists('fastcgi_finish_request'))
fastcgi_finish_request();
return $this;
}
}
?>