/
controller.php
92 lines (81 loc) · 2.04 KB
/
controller.php
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
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* Part of the Fuel framework.
*
* @package Fuel
* @version 1.0
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2012 Fuel Development Team
* @link http://fuelphp.com
*/
namespace Fuel\Core;
abstract class Controller
{
/**
* @var Request The current Request object
*/
public $request;
/**
* @var Response The current Response object
* @deprecated until v1.2
*/
public $response;
/**
* Sets the controller request object.
*
* @param Request The current request object
* @param Response The current response object
*/
public function __construct(\Request $request, \Response $response)
{
$this->request = $request;
$this->response = $response;
}
/**
* This method gets called before the action is called
*/
public function before() {}
/**
* This method gets called after the action is called
*/
public function after($response)
{
return $response;
}
/**
* This method returns the named parameter requested, or all of them
* if no parameter is given.
*
* @param string $param The name of the parameter
* @param mixed $default Default value
* @return mixed
*/
public function param($param, $default = null)
{
return $this->request->param($param, $default);
}
/**
* This method returns all of the named parameters.
*
* @return array
*/
public function params()
{
return $this->request->params();
}
/**
* Render a view and add it to the body
*
* @param string path to the view
* @param array variables for the view
* @param bool|null whether to use output encoding
* @deprecated until v1.2
*/
public function render($view, $data = array(), $auto_encode = null)
{
logger(\Fuel::L_WARNING, 'The response property of the controller is deprecated thus Controller::render() is of '.
'no use anymore. Use the render() function as an alternative for direct rendering, but it won\'t add to output.', __METHOD__);
$this->response->body .= \View::forge($view, $data, $auto_encode);
}
}