Airship\Engine\Continuum\Supplier::getChannels PHP Method

getChannels() public method

Get all of the channels
public getChannels ( ) : array
return array
    public function getChannels() : array
    {
        return $this->channels ?? [];
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * Get metadata about the package we're installing.
  *
  * @param string $minVersion
  * @return array
  * @throws NoAPIResponse
  */
 public function getPackageData(string $minVersion = '') : array
 {
     $channelsConfigured = $this->supplier->getChannels();
     if (empty($channelsConfigured)) {
         throw new NoAPIResponse(\trk('errors.hail.no_channel_configured', $this->supplier->getName()));
     }
     /**
      * HTTP POST arguments
      */
     $args = ['type' => $this->type, 'supplier' => $this->supplier->getName(), 'package' => $this->package];
     if (!empty($minVersion)) {
         $args['minimum'] = $minVersion;
     }
     /**
      * Let's try each of the channels this supplier
      * belongs to. This should in most cases only
      * run once.
      */
     foreach ($channelsConfigured as $channel) {
         $chan = $this->getChannel($channel);
         $publicKey = $chan->getPublicKey();
         // Iterate through all the available Channel URLs.
         // If the channel supports Tor, and we have tor-only
         // mode enabled, it will prioritize those URLs.
         foreach ($chan->getAllURLs() as $ch) {
             try {
                 $result = $this->hail->postSignedJSON($ch . API::get('version'), $publicKey, $args);
                 // Add the channel to this data...
                 $result['channel'] = $ch;
                 $result['minimum'] = (string) ($minVersion ?? '0.0.0');
                 return $result;
             } catch (TransferException $ex) {
                 $this->log('This channel URL did not respond.', LogLevel::INFO, ['channel' => $channel, 'url' => $ch, 'exception' => \Airship\throwableToArray($ex)]);
             } catch (SignatureFailed $ex) {
                 $this->log('Channel signature validation failed', LogLevel::WARNING, ['channel' => $channel, 'url' => $ch, 'exception' => \Airship\throwableToArray($ex)]);
             }
             // If we didn't return a result, we'll continue onto the next URL
         }
     }
     throw new NoAPIResponse(\trk('errors.hail.no_channel_responded'));
 }
All Usage Examples Of Airship\Engine\Continuum\Supplier::getChannels