Completed
Pull Request — master (#399)
by Elan
01:08
created

AbstractController::set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace XHGui;
4
5
use Slim\Http\Response;
6
use Slim\Slim as App;
7
use Slim\Views\Twig;
8
9
abstract class AbstractController
10
{
11
    /** @var App */
12
    private $app;
13
14
    public function __construct(App $app)
15
    {
16
        $this->app = $app;
17
    }
18
19
    protected function render(string $template, array $data = [])
20
    {
21
        /** @var Response $response */
22
        $response = $this->app->response;
23
        /** @var Twig $renderer */
24
        $renderer = $this->app->view;
25
26
        $renderer->appendData($data);
27
        $body = $renderer->fetch($template);
28
        $response->write($body);
29
    }
30
31
    protected function config(string $key)
32
    {
33
        return $this->app->config($key);
34
    }
35
}
36