1111use G4 \Runner \Presenter \HeaderAccept ;
1212use G4 \Runner \Route \Route ;
1313use G4 \Runner \Route \RouteFormatter ;
14+ use G4 \Version \Version ;
1415
1516abstract class RunnerAbstract implements RunnerInterface
1617{
@@ -65,6 +66,11 @@ abstract class RunnerAbstract implements RunnerInterface
6566 */
6667 private $ route ;
6768
69+ /**
70+ * @var string|null
71+ */
72+ private $ version ;
73+
6874 public function __construct ($ headerAccept = null )
6975 {
7076 $ this ->profiler = new Profiler ();
@@ -105,7 +111,7 @@ public function getApplicationService()
105111 */
106112 public function getHttpRequest ()
107113 {
108- if (null === $ this ->httpRequest ) {
114+ if (null === $ this ->httpRequest ) {
109115 $ this ->httpRequest = new \G4 \Http \Request ();
110116 }
111117 return $ this ->httpRequest ;
@@ -145,6 +151,12 @@ public function getRequestLogger()
145151 return $ this ->logger ;
146152 }
147153
154+ public function setApplicationVersion (Version $ version )
155+ {
156+ $ this ->version = $ version ->getVersionNumber ();
157+ return $ this ;
158+ }
159+
148160 public function registerFormatterBasic (FormatterInterface $ formatter )
149161 {
150162 $ this ->responseFormatter ->addBasic ($ formatter );
@@ -158,7 +170,7 @@ public function registerFormatterVerbose(FormatterInterface $formatter)
158170 }
159171
160172 //TODO: Drasko: refactor this!
161- public final function run ()
173+ final public function run ()
162174 {
163175 $ this ->route ();
164176 $ this ->parseApplicationMethod ();
@@ -169,7 +181,7 @@ public final function run()
169181
170182 $ this ->application ->run ();
171183
172- if (!$ this ->headerAccept instanceof HeaderAccept) {
184+ if (!$ this ->headerAccept instanceof HeaderAccept) {
173185 $ allowedMedia = $ this ->application ->getBootstrapFactory ()->getBootstrap ()->getAllowedMedia ();
174186 $ this ->headerAccept = new HeaderAccept ($ allowedMedia );
175187 }
@@ -198,13 +210,15 @@ private function getDataTransfer()
198210 $ this ->getHttpRequest (),
199211 $ this ->profiler ,
200212 $ this ->application ->getRequest (),
201- $ this ->application ->getResponse ());
213+ $ this ->application ->getResponse (),
214+ $ this ->version ?: null
215+ );
202216 }
203217
204218 private function getReqParams ()
205219 {
206220 $ params = $ this ->getHttpRequest ()->getParams ();
207- if (isset ($ this ->routerOptions ['url_part ' ]) && is_array ($ params )){
221+ if (isset ($ this ->routerOptions ['url_part ' ]) && is_array ($ params )) {
208222 $ params ['url_part ' ] = $ this ->routerOptions ['url_part ' ];
209223 }
210224 return $ params ;
0 commit comments