@@ 78-93 (lines=16) @@ | ||
75 | * @throws InvalidArgumentException |
|
76 | * @throws ReflectionException |
|
77 | */ |
|
78 | public static function setRelatedTickets($entity, array $tickets) |
|
79 | { |
|
80 | $relationName = 'Ticket'; |
|
81 | // Remove all the existing related tickets |
|
82 | $entity->_remove_relations($relationName); |
|
83 | ||
84 | foreach ($tickets as $ID) { |
|
85 | $parts = Relay::fromGlobalId($ID); |
|
86 | if (! empty($parts['id']) && absint($parts['id'])) { |
|
87 | $entity->_add_relation_to( |
|
88 | $parts['id'], |
|
89 | $relationName |
|
90 | ); |
|
91 | } |
|
92 | } |
|
93 | } |
|
94 | } |
|
95 |
@@ 81-97 (lines=17) @@ | ||
78 | * @param EE_Ticket $entity The Ticket instance. |
|
79 | * @param array $datetimes Array of datetime IDs to relate. |
|
80 | */ |
|
81 | public static function setRelatedDatetimes($entity, array $datetimes) |
|
82 | { |
|
83 | $relationName = 'Datetime'; |
|
84 | // Remove all the existing related datetimes |
|
85 | ||
86 | $entity->_remove_relations($relationName); |
|
87 | // @todo replace loop with single query |
|
88 | foreach ($datetimes as $ID) { |
|
89 | $parts = Relay::fromGlobalId($ID); |
|
90 | if (! empty($parts['id']) && absint($parts['id'])) { |
|
91 | $entity->_add_relation_to( |
|
92 | $parts['id'], |
|
93 | $relationName |
|
94 | ); |
|
95 | } |
|
96 | } |
|
97 | } |
|
98 | ||
99 | /** |
|
100 | * Sets the related prices for the given ticket. |
|
@@ 105-121 (lines=17) @@ | ||
102 | * @param EE_Ticket $entity The Ticket instance. |
|
103 | * @param array $prices Array of entity IDs to relate. |
|
104 | */ |
|
105 | public static function setRelatedPrices($entity, array $prices) |
|
106 | { |
|
107 | $relationName = 'Price'; |
|
108 | // Remove all the existing related entities |
|
109 | $entity->_remove_relations($relationName); |
|
110 | ||
111 | // @todo replace loop with single query |
|
112 | foreach ($prices as $ID) { |
|
113 | $parts = Relay::fromGlobalId($ID); |
|
114 | if (! empty($parts['id']) && absint($parts['id'])) { |
|
115 | $entity->_add_relation_to( |
|
116 | $parts['id'], |
|
117 | $relationName |
|
118 | ); |
|
119 | } |
|
120 | } |
|
121 | } |
|
122 | ||
123 | ||
124 | /** |