private static function Channel::getAllRoomsBatched in Rocket.Chat 8.2
Retrieve Chat <Method> Channels list. (in batch size).
@todo needs better Error checking / missing detection.
Parameters
\Drupal\rocket_chat_api\RocketChat\ApiClient $api:
array $rooms:
string $method (channels | groups):
int $offset:
int $size:
Return value
int Total number of Rooms of this <Method> found.
2 calls to Channel::getAllRoomsBatched()
- Channel::getAllChannelsBatched in modules/
rocket_chat_api/ src/ RocketChat/ Element/ Channel.php  - Retrieve Chat Public Channels list. (in batch size).
 - Channel::getAllGroupsBatched in modules/
rocket_chat_api/ src/ RocketChat/ Element/ Channel.php  - Retrieve Chat Private Groups list. (in batch size)
 
File
- modules/
rocket_chat_api/ src/ RocketChat/ Element/ Channel.php, line 227  
Class
Namespace
Drupal\rocket_chat_api\RocketChat\ElementCode
private static function getAllRoomsBatched(ApiClient &$api, array &$rooms, $method, $offset, $size) {
  $ret = $api
    ->getFromRocketChat("{$method}", [
    "query" => [
      "offset" => $offset,
      "count" => $size,
    ],
  ]);
  $methodParts = explode(".", $method, 2);
  foreach ($ret['body'][$methodParts[0]] as $index => $room) {
    $rooms[] = $room;
  }
  $total = $ret['body']['total'];
  $count = $ret['body']['count'];
  $retOffset = $ret['body']['offset'];
  $subTotal = $count * (1 + $retOffset);
  $roomsLeft = $total - $subTotal;
  if ($roomsLeft > 0) {
    self::getAllRoomsBatched($api, $rooms, $method, ++$offset, $size);
  }
  return $total;
}