|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain\services\admin\events\editor; |
|
4
|
|
|
|
|
5
|
|
|
use DomainException; |
|
6
|
|
|
use EE_Datetime; |
|
7
|
|
|
use EE_Error; |
|
8
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
|
9
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
|
10
|
|
|
use EventEspresso\core\exceptions\ModelConfigurationException; |
|
11
|
|
|
use EventEspresso\core\exceptions\UnexpectedEntityException; |
|
12
|
|
|
use InvalidArgumentException; |
|
13
|
|
|
use ReflectionException; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Class NewEventDefaultEntities |
|
17
|
|
|
* Description |
|
18
|
|
|
* |
|
19
|
|
|
* @package EventEspresso\core\domain\services\admin\events\editor |
|
20
|
|
|
* @author Brent Christensen |
|
21
|
|
|
* @since $VID:$ |
|
22
|
|
|
*/ |
|
23
|
|
|
class NewEventDefaultEntities extends EventEditorData |
|
24
|
|
|
{ |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* @param int $eventId |
|
28
|
|
|
* @return EE_Datetime[] |
|
29
|
|
|
* @throws DomainException |
|
30
|
|
|
* @throws EE_Error |
|
31
|
|
|
* @throws InvalidArgumentException |
|
32
|
|
|
* @throws InvalidDataTypeException |
|
33
|
|
|
* @throws InvalidInterfaceException |
|
34
|
|
|
* @throws ModelConfigurationException |
|
35
|
|
|
* @throws ReflectionException |
|
36
|
|
|
* @throws UnexpectedEntityException |
|
37
|
|
|
* @since $VID:$ |
|
38
|
|
|
*/ |
|
39
|
|
|
public function getData($eventId) |
|
40
|
|
|
{ |
|
41
|
|
|
$default_dates = $this->datetime_model->create_new_blank_datetime(); |
|
42
|
|
|
if (is_array($default_dates) && isset($default_dates[0]) && $default_dates[0] instanceof EE_Datetime) { |
|
43
|
|
|
// clone date, strip out ID, then save to get a new ID |
|
44
|
|
|
$default_date = clone $default_dates[0]; |
|
45
|
|
|
$default_date->set('DTT_ID', null); |
|
46
|
|
|
$default_date->save(); |
|
47
|
|
|
$default_date->_add_relation_to($eventId, 'Event'); |
|
48
|
|
|
$default_tickets = $this->ticket_model->get_all_default_tickets(); |
|
49
|
|
|
$default_prices = $this->price_model->get_all_default_prices(); |
|
50
|
|
|
foreach ($default_tickets as $default_ticket) { |
|
51
|
|
|
// clone ticket, strip out ID, then save to get a new ID |
|
52
|
|
|
$default_ticket_clone = clone $default_ticket; |
|
53
|
|
|
$default_ticket_clone->set('TKT_ID', null); |
|
54
|
|
|
$default_ticket_clone->save(); |
|
55
|
|
|
$default_ticket_clone->_add_relation_to($default_date, 'Datetime'); |
|
56
|
|
|
foreach ($default_prices as $default_price) { |
|
|
|
|
|
|
57
|
|
|
// clone price, strip out ID, then save to get a new ID |
|
58
|
|
|
$default_price_clone = clone $default_price; |
|
59
|
|
|
$default_price_clone->set('PRC_ID', null); |
|
60
|
|
|
$default_price_clone->save(); |
|
61
|
|
|
$default_price_clone->_add_relation_to($default_ticket_clone, 'Ticket'); |
|
62
|
|
|
} |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
return $default_dates; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.