1 | <?php |
||
37 | abstract class DispatchAction extends BaseAction implements DispatchActionInterface |
||
38 | { |
||
39 | |||
40 | /** |
||
41 | * The default action method suffix. |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | const ACTION_SUFFIX = 'Action'; |
||
46 | |||
47 | /** |
||
48 | * Holds the name of the default method to invoke if the parameter with the method name to invoke is not specified. |
||
49 | * |
||
50 | * @var string |
||
51 | */ |
||
52 | const DEFAULT_METHOD_NAME = 'index'; |
||
53 | |||
54 | /** |
||
55 | * The servlet request instance. |
||
56 | * |
||
57 | * @var \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface |
||
58 | */ |
||
59 | protected $servletRequest; |
||
60 | |||
61 | /** |
||
62 | * The servlet response instance. |
||
63 | * |
||
64 | * @var \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface |
||
65 | */ |
||
66 | protected $servletResponse; |
||
67 | |||
68 | /** |
||
69 | * Implemented to comply witht the interface. |
||
70 | * |
||
71 | * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance |
||
72 | * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The response instance |
||
73 | * |
||
74 | * @return string|null The action result |
||
75 | */ |
||
76 | 1 | public function perform(HttpServletRequestInterface $servletRequest, HttpServletResponseInterface $servletResponse) |
|
89 | |||
90 | /** |
||
91 | * This method returns the default method name we'll invoke if the path info doesn't contain |
||
92 | * the method name, that'll be the second element, when we explode the path info with a slash. |
||
93 | * |
||
94 | * @return string The default action method name that has to be invoked |
||
95 | */ |
||
96 | 1 | public function getDefaultMethod() |
|
100 | |||
101 | /** |
||
102 | * This method returns the action suffix, or prepends the action suffix to the passed action |
||
103 | * method name and returns it. |
||
104 | * |
||
105 | * @param string $requestedMethodName The action method name to append the suffix to |
||
106 | * |
||
107 | * @return string The action suffix or the action method name, prepended with the action suffix |
||
108 | */ |
||
109 | 1 | protected function getActionSuffix($requestedMethodName) |
|
113 | |||
114 | /** |
||
115 | * Sets the servlet request instance. |
||
116 | * |
||
117 | * @param \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface $servletRequest The request instance |
||
118 | * |
||
119 | * @return void |
||
120 | */ |
||
121 | 2 | public function setServletRequest(HttpServletRequestInterface $servletRequest) |
|
125 | |||
126 | /** |
||
127 | * Sets the servlet response instance. |
||
128 | * |
||
129 | * @param \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface $servletResponse The request instance |
||
130 | * |
||
131 | * @return void |
||
132 | */ |
||
133 | 2 | public function setServletResponse(HttpServletResponseInterface $servletResponse) |
|
137 | |||
138 | /** |
||
139 | * Returns the servlet response instance. |
||
140 | * |
||
141 | * @return \AppserverIo\Psr\Servlet\Http\HttpServletRequestInterface The request instance |
||
142 | */ |
||
143 | 1 | public function getServletRequest() |
|
147 | |||
148 | /** |
||
149 | * Returns the servlet request instance. |
||
150 | * |
||
151 | * @return \AppserverIo\Psr\Servlet\Http\HttpServletResponseInterface The response instance |
||
152 | */ |
||
153 | 1 | public function getServletResponse() |
|
157 | } |
||
158 |