Passed
Branch tmp/scrutinizer-abstract-notif... (9deb43)
by Romain
08:27 queued 03:54
created

EntityNotification::getEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * Copyright (C) 2018
5
 * Nathan Boiron <[email protected]>
6
 * Romain Canon <[email protected]>
7
 *
8
 * This file is part of the TYPO3 NotiZ project.
9
 * It is free software; you can redistribute it and/or modify it
10
 * under the terms of the GNU General Public License, either
11
 * version 3 of the License, or any later version.
12
 *
13
 * For the full copyright and license information, see:
14
 * http://www.gnu.org/licenses/gpl-3.0.html
15
 */
16
17
namespace CuyZ\Notiz\Domain\Notification;
18
19
use CuyZ\Notiz\Core\Definition\Tree\Notification\Channel\ChannelDefinition;
20
use CuyZ\Notiz\Core\Notification\MultipleChannelsNotification;
21
use CuyZ\Notiz\Core\Notification\Notification;
22
use TYPO3\CMS\Core\Utility\GeneralUtility;
23
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
24
use TYPO3\CMS\Extbase\Service\FlexFormService;
25
26
abstract class EntityNotification extends AbstractEntity implements Notification, MultipleChannelsNotification
27
{
28
    /**
29
     * @var string
30
     */
31
    protected $title;
32
33
    /**
34
     * @var string
35
     */
36
    protected $event;
37
38
    /**
39
     * @var string
40
     */
41
    protected $channel;
42
43
    /**
44
     * @var string
45
     */
46
    protected $eventConfigurationFlex;
47
48
    /**
49
     * @var array
50
     */
51
    protected $eventConfiguration;
52
53
    /**
54
     * @return string
55
     */
56
    public function getTitle()
57
    {
58
        return $this->title;
59
    }
60
61
    /**
62
     * @param string $title
63
     */
64
    public function setTitle($title)
65
    {
66
        $this->title = $title;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getEvent()
73
    {
74
        return $this->event;
75
    }
76
77
    /**
78
     * @param string $event
79
     */
80
    public function setEvent($event)
81
    {
82
        $this->event = $event;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getChannel()
89
    {
90
        return $this->channel;
91
    }
92
93
    /**
94
     * @param string $channel
95
     */
96
    public function setChannel($channel)
97
    {
98
        $this->channel = $channel;
99
    }
100
101
    /**
102
     * @param string $eventConfigurationFlex
103
     */
104
    public function setEventConfigurationFlex($eventConfigurationFlex)
105
    {
106
        $this->eventConfigurationFlex = $eventConfigurationFlex;
107
    }
108
109
    /**
110
     * Returns the event configuration stored as a FlexForm string.
111
     *
112
     * @return array
113
     */
114
    public function getEventConfiguration()
115
    {
116
        if (null === $this->eventConfiguration) {
117
            /** @var FlexFormService $flexFormService */
118
            $flexFormService = GeneralUtility::makeInstance(FlexFormService::class);
119
120
            $this->eventConfiguration = $flexFormService->convertFlexFormContentToArray($this->eventConfigurationFlex);
121
        }
122
123
        return $this->eventConfiguration;
124
    }
125
126
    /**
127
     * The selected channel is stored in the `$channel` property.
128
     *
129
     * @inheritdoc
130
     */
131
    public function shouldDispatch(ChannelDefinition $definition)
132
    {
133
        return $definition->getClassName() === $this->getChannel();
134
    }
135
}
136