Airship\Engine\Continuum\Installer::getPackageData PHP Method

getPackageData() public method

Get metadata about the package we're installing.
public getPackageData ( string $minVersion = '' ) : array
$minVersion string
return array
    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'));
    }