1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Vectorface\SnappyRouter\Request; |
4
|
|
|
|
5
|
|
|
use Vectorface\SnappyRouter\Controller\AbstractController; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* The base class for all requests. Implements the standard RequestInterface. |
9
|
|
|
* @copyright Copyright (c) 2014, VectorFace, Inc. |
10
|
|
|
* @author Dan Bruce <[email protected]> |
11
|
|
|
*/ |
12
|
|
|
class AbstractRequest implements RequestInterface |
13
|
|
|
{ |
14
|
|
|
/** The controller to use in the request. */ |
15
|
|
|
private $controller; |
16
|
|
|
/** The action to invoke in the request. */ |
17
|
|
|
private $action; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Constructor for the abstract request. |
21
|
|
|
* @param string $controller The controller to be used. |
22
|
|
|
* @param string $action The action to be invoked. |
23
|
|
|
*/ |
24
|
42 |
|
public function __construct($controller, $action) |
25
|
|
|
{ |
26
|
42 |
|
$this->setController($controller); |
27
|
42 |
|
$this->setAction($action); |
28
|
42 |
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Returns the controller to be used in the request. |
32
|
|
|
* @return string Returns the controller DI key to be used in the request. |
33
|
|
|
*/ |
34
|
22 |
|
public function getController() |
35
|
|
|
{ |
36
|
22 |
|
return $this->controller; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Sets the controller to be used in the request. |
41
|
|
|
* @param string $controller The controller DI key to be used in the request. |
42
|
|
|
* @return RequestInterface Returns $this. |
43
|
|
|
*/ |
44
|
42 |
|
public function setController($controller) |
45
|
|
|
{ |
46
|
42 |
|
$this->controller = $controller; |
47
|
42 |
|
return $this; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* Returns the action to be invoked as a string. |
52
|
|
|
* @return string The action to be invoked. |
53
|
|
|
*/ |
54
|
21 |
|
public function getAction() |
55
|
|
|
{ |
56
|
21 |
|
return $this->action; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Sets the action to be invoked by the request |
61
|
|
|
* @param string $action The action to be invoked by the request. |
62
|
|
|
* @return RequestInterface Returns $this. |
63
|
|
|
*/ |
64
|
42 |
|
public function setAction($action) |
65
|
|
|
{ |
66
|
42 |
|
$this->action = (string)$action; |
67
|
42 |
|
return $this; |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|