@@ 65-80 (lines=16) @@ | ||
62 | * @param EE_Datetime $entity The datetime instance. |
|
63 | * @param array $tickets Array of ticket IDs to relate. |
|
64 | */ |
|
65 | public static function setRelatedTickets($entity, array $tickets) |
|
66 | { |
|
67 | $relationName = 'Ticket'; |
|
68 | // Remove all the existing related tickets |
|
69 | $entity->_remove_relations($relationName); |
|
70 | ||
71 | foreach ($tickets as $ID) { |
|
72 | $parts = Relay::fromGlobalId($ID); |
|
73 | if (! empty($parts['id']) && absint($parts['id'])) { |
|
74 | $entity->_add_relation_to( |
|
75 | $parts['id'], |
|
76 | $relationName |
|
77 | ); |
|
78 | } |
|
79 | } |
|
80 | } |
|
81 | } |
|
82 |
@@ 58-74 (lines=17) @@ | ||
55 | * @param EE_Ticket $entity The Ticket instance. |
|
56 | * @param array $datetimes Array of datetime IDs to relate. |
|
57 | */ |
|
58 | public static function setRelatedDatetimes($entity, array $datetimes) |
|
59 | { |
|
60 | $relationName = 'Datetime'; |
|
61 | // Remove all the existing related datetimes |
|
62 | ||
63 | $entity->_remove_relations($relationName); |
|
64 | // @todo replace loop with single query |
|
65 | foreach ($datetimes as $ID) { |
|
66 | $parts = Relay::fromGlobalId($ID); |
|
67 | if (! empty($parts['id']) && absint($parts['id'])) { |
|
68 | $entity->_add_relation_to( |
|
69 | $parts['id'], |
|
70 | $relationName |
|
71 | ); |
|
72 | } |
|
73 | } |
|
74 | } |
|
75 | ||
76 | /** |
|
77 | * Sets the related prices for the given ticket. |
|
@@ 82-98 (lines=17) @@ | ||
79 | * @param EE_Ticket $entity The Ticket instance. |
|
80 | * @param array $prices Array of entity IDs to relate. |
|
81 | */ |
|
82 | public static function setRelatedPrices($entity, array $prices) |
|
83 | { |
|
84 | $relationName = 'Price'; |
|
85 | // Remove all the existing related entities |
|
86 | $entity->_remove_relations($relationName); |
|
87 | ||
88 | // @todo replace loop with single query |
|
89 | foreach ($prices as $ID) { |
|
90 | $parts = Relay::fromGlobalId($ID); |
|
91 | if (! empty($parts['id']) && absint($parts['id'])) { |
|
92 | $entity->_add_relation_to( |
|
93 | $parts['id'], |
|
94 | $relationName |
|
95 | ); |
|
96 | } |
|
97 | } |
|
98 | } |
|
99 | } |
|
100 |