1: <?php
2:
3: namespace PHPixie\Framework\Processors\HTTP\Response;
4:
5: /**
6: * Processor that handles requests
7: * that did not match any route
8: */
9: class NotFound implements \PHPixie\Processors\Processor
10: {
11: /**
12: * @var \PHPixie\HTTP
13: */
14: protected $http;
15:
16: /**
17: * @var \PHPixie\Template
18: */
19: protected $template;
20:
21: /**
22: * @var \PHPixie\Slice\Data
23: */
24: protected $configData;
25:
26: /**
27: * Constructor
28: * @param \PHPixie\HTTP $http
29: * @param \PHPixie\Template $template
30: * @param \PHPixie\Slice\Data $configData
31: */
32: public function __construct($http, $template, $configData)
33: {
34: $this->http = $http;
35: $this->template = $template;
36: $this->configData = $configData;
37: }
38:
39: /**
40: * Build a response for when a uri does not exist
41: * @param \PHPixie\HTTP\Request $request
42: * @return \PHPixie\HTTP\Responses\Response
43: */
44: public function process($request)
45: {
46: $templateName = $this->configData->getRequired('template');
47:
48: $body = $this->template->render(
49: $templateName,
50: array(
51: 'request' => $request
52: )
53: );
54:
55: return $this->http->responses()->response($body, array(), 404);
56: }
57: }