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\Core\Notification\Processor; |
18
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Definition\Tree\EventGroup\Event\EventDefinition; |
20
|
|
|
use CuyZ\Notiz\Core\Notification\Notification; |
21
|
|
|
use CuyZ\Notiz\Domain\Repository\EntityNotificationRepository; |
22
|
|
|
|
23
|
|
|
abstract class EntityNotificationProcessor extends NotificationProcessor |
24
|
|
|
{ |
25
|
|
|
/** |
26
|
|
|
* The repository needs to be injected in the child class. |
27
|
|
|
* |
28
|
|
|
* @var EntityNotificationRepository |
29
|
|
|
*/ |
30
|
|
|
protected $notificationRepository; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @param EventDefinition $definition |
34
|
|
|
* @return Notification[] |
35
|
|
|
*/ |
36
|
|
|
public function getNotificationsFromEventDefinition(EventDefinition $definition) |
37
|
|
|
{ |
38
|
|
|
return $this->notificationRepository |
39
|
|
|
->findFromEventDefinition($definition) |
40
|
|
|
->toArray(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param EventDefinition $definition |
45
|
|
|
* @return int |
46
|
|
|
*/ |
47
|
|
|
public function countNotificationsFromEventDefinition(EventDefinition $definition) |
48
|
|
|
{ |
49
|
|
|
return $this->notificationRepository->countFromEventDefinition($definition); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @param string $identifier |
54
|
|
|
* @return Notification|object |
55
|
|
|
*/ |
56
|
|
|
public function getNotificationFromIdentifier($identifier) |
57
|
|
|
{ |
58
|
|
|
return $this->notificationRepository->findByIdentifierForce($identifier); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @return Notification[] |
63
|
|
|
*/ |
64
|
|
|
public function getAllNotifications() |
65
|
|
|
{ |
66
|
|
|
return $this->notificationRepository |
67
|
|
|
->findAll() |
68
|
|
|
->toArray(); |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @return int |
73
|
|
|
*/ |
74
|
|
|
public function getTotalNumber() |
75
|
|
|
{ |
76
|
|
|
return $this->notificationRepository |
77
|
|
|
->findAll() |
78
|
|
|
->count(); |
79
|
|
|
} |
80
|
|
|
} |
81
|
|
|
|