Test Failed
Pull Request — master (#150)
by Alexander
12:20
created

BeforeRender::getParameters()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\View\Event\WebView;
6
7
use Psr\EventDispatcher\StoppableEventInterface;
8
use Yiisoft\View\WebView;
9
10
/**
11
 * `BeforeRender` event is triggered by {@see WebView::renderFile()} right before it renders a view file.
12
 */
13
class BeforeRender implements StoppableEventInterface
14
{
15
    private WebView $view;
16
17
    /**
18
     * @var string The view file being rendered.
19
     */
20
    private string $file;
21
22
    /**
23
     * @var array The parameters array passed to the {@see WebView::render()} or {@see WebView::renderFile()} method.
24
     */
25
    private array $parameters;
26
27
    private bool $stopPropagation = false;
28
29
    public function __construct(WebView $view, string $file, array $parameters)
30
    {
31
        $this->view = $view;
32
        $this->file = $file;
33
        $this->parameters = $parameters;
34
    }
35
36
    public function stopPropagation(): void
37
    {
38
        $this->stopPropagation = true;
39
    }
40
41
    public function isPropagationStopped(): bool
42
    {
43
        return $this->stopPropagation;
44
    }
45
46
    public function getView(): WebView
47
    {
48
        return $this->view;
49
    }
50
51
    public function getFile(): string
52
    {
53
        return $this->file;
54
    }
55
56
    public function getParameters(): array
57
    {
58
        return $this->parameters;
59
    }
60
}
61