Completed
Push — master ( cbb4bb...9fe020 )
by Mikael
10:38
created

Page   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 48
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B render() 0 24 1
1
<?php
2
3
namespace Anax\Page;
4
5
use \Anax\DI\InjectionAwareInterface;
6
use \Anax\DI\InjectionAwareTrait;
7
8
/**
9
 * A default page rendering class.
10
 */
11
class Page implements /* PageRenderInterface, */ InjectionAwareInterface
12
{
13
    use InjectionAwareTrait;
14
15
16
17
    /**
18
     * @var string $namespace A namespace to prepend each template file.
19
     */
20
    private $namespace = "anax/v1";
21
22
23
24
    /**
25
     * Render a standard web page using a specific layout.
26
     *
27
     * @param array   $data   variables to expose to layout view.
28
     * @param integer $status code to use when delivering the result.
29
     *
30
     * @return void
31
     *
32
     * @SuppressWarnings(PHPMD.ExitExpression)
33
     */
34
    public function render($data, $status = 200)
35
    {
36
        // Get the view container, holding all views
37
        $view = $this->di->get("view");
38
39
        // Add static assets
40
        // $data["favicon"] = "favicon.ico";
41
        // $data["stylesheets"] = ["css/style.css"];
42
        // $data["javascripts"] = ["js/main.js"];
43
44
        // Add views for common header, navbar and footer
45
        $view->add("{$this->namespace}/header/default", $data, "header");
46
        $view->add("{$this->namespace}/navbar/default", $data, "navbar");
47
        $view->add("{$this->namespace}/footer/default", $data, "footer");
48
49
        // Add view for the overall layout, use region "layout"
50
        $view->add("{$this->namespace}/layout/default", $data, "layout");
51
52
        // Render all views, using the region "layout",
53
        // add to response and send.
54
        $body = $view->renderBuffered("layout");
55
        $this->di->get("response")->setBody($body)->send($status);
56
        exit;
57
    }
58
}
59