You are here

public function MolliePaymentInstaller::installMollieApiClient in Mollie Payment 7.2

Installs the Mollie API client for PHP.

File

includes/mollie_payment.installer.inc, line 188

Class

MolliePaymentInstaller
Class MolliePaymentInstaller.

Namespace

Drupal\mollie_payment

Code

public function installMollieApiClient() {
  try {

    // We cannot use system_retrieve_file() since it utilizes
    // drupal_http_request() which in turn does not properly update the Host
    // header when following redirects. That causes an issue when GitHub
    // redirects to AWS.
    $file_uri = $this
      ->downloadLatestsMollieApiClient();

    // Extract the archive to the libraries directory.
    $directory = 'sites/all/libraries/' . self::LIBRARY_NAME;
    if (module_exists('update')) {
      update_manager_archive_extract(drupal_realpath($file_uri), $directory);
    }
    else {
      $this
        ->extractArchive(drupal_realpath($file_uri), $directory);
    }

    // Clear the libraries cache.
    libraries_cache_clear();
    drupal_set_message(t('The Mollie API client for PHP has been installed.'));
  } catch (\Exception $e) {
    watchdog_exception('mollie_payment', $e);
    drupal_set_message(t('The Mollie API client for PHP could not be installed. See the logs for details.'));
  }
}