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