xero-8.x-2.x-dev/xero.install

xero.install
<?php

/**
 * @file
 * Xero installation routines.
 */

use Drupal\Core\StringTranslation\TranslatableMarkup;
use Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException;

/**
 * Implements hook_requirements().
 */
function xero_requirements($phase) {
  $requirements = [];

  if ($phase === 'runtime') {
    try {
      $client = \Drupal::service('xero.client');
    }
    catch (ServiceNotFoundException $e) {
      $client = FALSE;
    }

    $requirements['xero'] = [
      'title' => new TranslatableMarkup('Xero'),
      'value' => new TranslatableMarkup('Xero API module is configured.'),
      'severity' => REQUIREMENT_OK,
    ];

    if ($client === FALSE) {
      $requirements['xero']['value'] = new TranslatableMarkup('Xero API could not instantiate XeroClient. Please check the configuration and logs.');
      $requirements['xero']['severity'] = REQUIREMENT_ERROR;
    }
  }

  return $requirements;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc