- array_merge: documentation ( source)
<?php
// THIS IS SYNC CODE
/** Make the calls **/
foreach ($callsToMake as $serverClients)
{
foreach ($serverClients as $keys)
{
/** @var ConnectionConfig $clientConfig */
$clientConfig = $keys['config'];
/** Transport returns json **/
$transport = $this->transportFactory->build($this->client, $this->request, $clientConfig);
/** Adapter returns Torrent objects **/
$adapter = $this->adapterFactory->build($transport);
$torrents = array_merge($torrents, $adapter->getTorrents($keys['hashes']));
}
}
return $torrents;
// TRYING TO MAKE IT ASYNC WITH $callable
/** Make the calls **/
foreach ($callsToMake as $serverClients)
{
foreach ($serverClients as $keys)
{
/** @var ConnectionConfig $clientConfig */
$clientConfig = $keys['config'];
/** Transport returns json **/
$transport = $this->transportFactory->build($this->client, $this->request, $clientConfig, $async = true);
/** Adapter returns Torrent objects **/
$adapter = $this->adapterFactory->build($transport);
$torrents = array_merge($torrents, $adapter->getTorrents($keys['hashes'], $callable)); // Obviously, this will only happen once
}
}