Fix array merge issue on refactoring mqtt client #730

This commit is contained in:
Ramon Gutierrez 2023-05-04 17:38:10 +08:00
parent 13531171d7
commit df6a4ad292

View file

@ -43,13 +43,21 @@ class MQTTClient
$new_sessions = []; $new_sessions = [];
$cust_user = $job_order->getCustomer()->getCustomerUser(); $cust_user = $job_order->getCustomer()->getCustomerUser();
if (!empty($cust_user)) { if ($cust_user->isEmpty()) {
$new_sessions = $cust_user->getMobileSessions(); $new_sessions = $cust_user->getMobileSessions();
} }
$sessions = array_merge($legacy_sessions, $new_sessions); // TODO: make this more elegant since getPhoneNumber() might differ later on // TODO: make this more elegant. looping through each instead of merging the two because doctrine returns PersistentCollection if empty, and array if not
$sessions = [];
foreach ($legacy_sessions as $sess) {
$sessions[] = $sess;
}
if (count($sessions) == 0) foreach ($new_sessions as $sess) {
$sessions[] = $sess;
}
if (empty($sessions))
{ {
error_log("no sessions to send mqtt event to"); error_log("no sessions to send mqtt event to");
return; return;