Fix array merge issue on refactoring mqtt client #730
This commit is contained in:
parent
13531171d7
commit
df6a4ad292
1 changed files with 12 additions and 4 deletions
|
|
@ -43,18 +43,26 @@ class MQTTClient
|
|||
|
||||
$new_sessions = [];
|
||||
$cust_user = $job_order->getCustomer()->getCustomerUser();
|
||||
if (!empty($cust_user)) {
|
||||
if ($cust_user->isEmpty()) {
|
||||
$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");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$channels = [];
|
||||
|
||||
// send to every customer session
|
||||
|
|
|
|||
Loading…
Reference in a new issue