You are here

public function MolliePaymentInstaller::checkMollieApiClient in Mollie Payment 7.2

Checks if the Mollie API client for PHP is installed.

Return value

array An associative array as expected by hook_requirements().

File

includes/mollie_payment.installer.inc, line 34

Class

MolliePaymentInstaller
Class MolliePaymentInstaller.

Namespace

Drupal\mollie_payment

Code

public function checkMollieApiClient() {

  // Default requirements info.
  $value = 'not found';
  $description = t('The Mollie API client for PHP is missing.');
  $severity = REQUIREMENT_WARNING;

  // Try to detect the installation state of the Mollie API client for PHP.
  $library = libraries_detect(self::LIBRARY_NAME);
  if ($library) {
    if ($library['installed']) {

      // The client is installed. Show the installed version.
      $value = $library['version'];
      $description = t('Version @version of the Mollie API client for PHP is installed.', array(
        '@version' => $library['version'],
      ));
      $severity = REQUIREMENT_OK;
    }
    else {

      // The client is not installed. Show the error and error message.
      $value = $library['error'];
      $description = $library['error message'];

      // Add a link to the client installer.
      $description .= ' ' . t('Click to <a href="!url">install the Mollie API client for PHP</a>.', array(
        '!url' => url('admin/config/services/mollie/client-installer', array(
          'query' => array(
            'destination' => current_path(),
          ),
        )),
      ));
    }
  }
  return $this
    ->formatRequirements('Mollie API client for PHP', $value, $description, $severity);
}