1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\admin\events\editor; |
4
|
|
|
|
5
|
|
|
use EE_Error; |
6
|
|
|
use EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes; |
7
|
|
|
use EventEspresso\core\domain\entities\admin\GraphQLData\Event; |
8
|
|
|
use EventEspresso\core\domain\entities\admin\GraphQLData\Prices; |
9
|
|
|
use EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes; |
10
|
|
|
use EventEspresso\core\domain\entities\admin\GraphQLData\Tickets; |
11
|
|
|
use ReflectionException; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Class EventEditorGraphQLData |
15
|
|
|
* Assembles GraphQL entity data for the Event Editor |
16
|
|
|
* |
17
|
|
|
* @package EventEspresso\core\domain\services\admin\events\editor |
18
|
|
|
* @author Manzoor Wani |
19
|
|
|
* @since $VID:$ |
20
|
|
|
*/ |
21
|
|
|
class EventEditorGraphQLData |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var Event $event |
26
|
|
|
*/ |
27
|
|
|
protected $event; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var Datetimes $datetimes |
31
|
|
|
*/ |
32
|
|
|
protected $datetimes; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var Prices $prices |
36
|
|
|
*/ |
37
|
|
|
protected $prices; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var PriceTypes $price_types |
41
|
|
|
*/ |
42
|
|
|
protected $price_types; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var Tickets $tickets |
46
|
|
|
*/ |
47
|
|
|
protected $tickets; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var EventEntityRelations $relations |
51
|
|
|
*/ |
52
|
|
|
protected $relations; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var EventManagers $managers |
56
|
|
|
*/ |
57
|
|
|
protected $managers; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var NewEventDefaultEntities $default_entities |
61
|
|
|
*/ |
62
|
|
|
protected $default_entities; |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* EventEditorGraphQLData constructor. |
67
|
|
|
* |
68
|
|
|
* @param Datetimes $datetimes |
69
|
|
|
* @param Event $event |
70
|
|
|
* @param Prices $prices |
71
|
|
|
* @param PriceTypes $price_types |
72
|
|
|
* @param Tickets $tickets |
73
|
|
|
* @param EventEntityRelations $relations |
74
|
|
|
* @param EventManagers $managers |
75
|
|
|
* @param NewEventDefaultEntities $default_entities |
76
|
|
|
*/ |
77
|
|
|
public function __construct( |
78
|
|
|
Datetimes $datetimes, |
79
|
|
|
Event $event, |
80
|
|
|
Prices $prices, |
81
|
|
|
PriceTypes $price_types, |
82
|
|
|
Tickets $tickets, |
83
|
|
|
EventEntityRelations $relations, |
84
|
|
|
EventManagers $managers, |
85
|
|
|
NewEventDefaultEntities $default_entities |
86
|
|
|
) { |
87
|
|
|
$this->datetimes = $datetimes; |
88
|
|
|
$this->event = $event; |
89
|
|
|
$this->default_entities = $default_entities; |
90
|
|
|
$this->prices = $prices; |
91
|
|
|
$this->price_types = $price_types; |
92
|
|
|
$this->managers = $managers; |
93
|
|
|
$this->relations = $relations; |
94
|
|
|
$this->tickets = $tickets; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* @param int $eventId |
100
|
|
|
* @return array |
101
|
|
|
* @throws EE_Error |
102
|
|
|
* @throws ReflectionException |
103
|
|
|
* @since $VID:$ |
104
|
|
|
*/ |
105
|
|
|
public function getData(int $eventId) |
106
|
|
|
{ |
107
|
|
|
$event = $this->event->getData(['id' => $eventId]); |
108
|
|
|
$datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
109
|
|
|
$eventManagers = $this->managers ->getData($eventId); |
110
|
|
|
|
111
|
|
|
// Avoid undefined variable warning in PHP >= 7.3 |
112
|
|
|
$tickets = null; |
|
|
|
|
113
|
|
|
$prices = null; |
|
|
|
|
114
|
|
|
|
115
|
|
|
if (empty($datetimes['nodes']) || (isset($_REQUEST['action']) && $_REQUEST['action'] === 'create_new')) { |
116
|
|
|
$this->default_entities->getData($eventId); |
117
|
|
|
$datetimes = $this->datetimes->getData(['eventId' => $eventId]); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
$tickets = $this->tickets->getData([ |
121
|
|
|
'eventId' => $eventId, |
122
|
|
|
'includeDefaultTickets' => true, |
123
|
|
|
]); |
124
|
|
|
|
125
|
|
|
$prices = $this->prices->getData([ |
126
|
|
|
'eventId' => $eventId, |
127
|
|
|
'includeDefaultTicketsPrices' => true, |
128
|
|
|
'includeDefaultPrices' => true, |
129
|
|
|
]); |
130
|
|
|
|
131
|
|
|
$priceTypes = $this->price_types->getData(); |
132
|
|
|
|
133
|
|
|
$relations = $this->relations->getData($eventId); |
134
|
|
|
|
135
|
|
|
return compact( |
136
|
|
|
'datetimes', |
137
|
|
|
'event', |
138
|
|
|
'eventManagers', |
139
|
|
|
'prices', |
140
|
|
|
'priceTypes', |
141
|
|
|
'relations', |
142
|
|
|
'tickets' |
143
|
|
|
); |
144
|
|
|
} |
145
|
|
|
} |
146
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.