Completed
Push — master ( 7b9015...c5b311 )
by Vladimir
26s queued 11s
created

RedirectPreOutput::getParentPageView()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
crap 2
1
<?php
2
3
namespace allejo\stakx\Event;
4
5
use allejo\stakx\Document\BasePageView;
6
use Symfony\Component\EventDispatcher\Event;
7
8
/**
9
 * This event is fired before a redirect is created. This event provides read-only access to the parent PageView and
10
 * write access to the PageView generated to write a flat redirect file.
11
 *
12
 * @since 0.2.1
13
 */
14
class RedirectPreOutput extends Event
15
{
16
    const NAME = 'redirect.preoutput';
17
18
    /** @var string */
19
    private $fromUrl;
20
21
    /** @var string */
22
    private $toUrl;
23
24
    /** @var BasePageView */
25
    private $parentPageView;
26
27
    /** @var BasePageView */
28
    private $redirectPageView;
29
30
    /**
31
     * @param string       $from
32
     * @param string       $to
33
     * @param BasePageView $pageView
34
     * @param BasePageView $redirectPageView
35
     */
36 2
    public function __construct($from, $to, $pageView, $redirectPageView)
37
    {
38 2
        $this->fromUrl = $from;
39 2
        $this->toUrl = $to;
40 2
        $this->parentPageView = $pageView;
41 2
        $this->redirectPageView = $redirectPageView;
42 2
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getFromUrl()
48
    {
49
        return $this->fromUrl;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getToUrl()
56
    {
57
        return $this->toUrl;
58
    }
59
60
    /**
61
     * Read-only access to the PageView who this redirect belongs to.
62
     *
63
     * @return BasePageView
64
     */
65
    public function getParentPageView()
66
    {
67
        return clone $this->parentPageView;
68
    }
69
70
    /**
71
     * The PageView that was generated to create this redirect as a flat file.
72
     *
73
     * @return BasePageView
74
     */
75
    public function getRedirectPageView()
76
    {
77
        return $this->redirectPageView;
78
    }
79
}
80