-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlatesView.php
More file actions
54 lines (45 loc) · 1.14 KB
/
PlatesView.php
File metadata and controls
54 lines (45 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
declare(strict_types=1);
namespace Lit\View\Plates;
use League\Plates\Engine;
use Lit\Air\Configurator as C;
use Lit\Voltage\AbstractView;
use Psr\Http\Message\ResponseInterface;
class PlatesView extends AbstractView
{
/**
* @var Engine
*/
protected $engine;
/**
* @var string
*/
protected $name;
public function __construct(Engine $engine, string $name)
{
$this->engine = $engine;
$this->name = $name;
}
public static function configuration(array $engineParams)
{
return [
PlatesViewFactory::class => C::provideParameter([
C::alias(PlatesViewFactory::class, Engine::class)
]),
C::join(PlatesViewFactory::class, Engine::class) => C::instance(Engine::class, $engineParams),
];
}
public function render(array $data = []): ResponseInterface
{
$body = $this->getEmptyBody();
$body->write($this->engine->render($this->name, $data));
return $this->response;
}
/**
* @return Engine
*/
public function getEngine(): Engine
{
return $this->engine;
}
}