PhantomInstaller\Installer::download PHP Метод

download() публичный Метод

The package to download is created on the fly. For downloading Composer\DownloadManager is used. Downloads are automatically retried with a lower version number, when the resource it not found (404).
public download ( string $targetDir, string $version ) : boolean
$targetDir string
$version string
Результат boolean
    public function download($targetDir, $version)
    {
        $io = $this->getIO();
        $downloadManager = $this->getComposer()->getDownloadManager();
        $retries = count($this->getPhantomJsVersions());
        while ($retries--) {
            $package = $this->createComposerInMemoryPackage($targetDir, $version);
            try {
                $downloadManager->download($package, $targetDir, false);
                return true;
            } catch (TransportException $e) {
                if ($e->getStatusCode() === 404) {
                    $version = $this->getLowerVersion($version);
                    $io->warning('Retrying the download with a lower version number: "' . $version . '"');
                }
            } catch (\Exception $e) {
                $message = $e->getMessage();
                $io->error(PHP_EOL . '<error>While downloading version ' . $version . ' the following error accoured: ' . $message . '</error>');
                return false;
            }
        }
    }