You are here

function tmgmt_smartling_requirements in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 tmgmt_smartling.module \tmgmt_smartling_requirements()
  2. 8.2 tmgmt_smartling.module \tmgmt_smartling_requirements()

Implements hook_requirements().

File

./tmgmt_smartling.module, line 297
Contains

Code

function tmgmt_smartling_requirements($phase) {
  $requirements = [];
  if ($phase == 'runtime') {
    $user_id = \Drupal::config('tmgmt.translator.smartling')
      ->get('settings.user_id');
    $token_secret = \Drupal::config('tmgmt.translator.smartling')
      ->get('settings.token_secret');
    if (empty($user_id) || empty($token_secret)) {
      $missing_settings = [];
      if (empty($user_id)) {
        $missing_settings[] = 'User ID';
      }
      if (empty($token_secret)) {
        $missing_settings[] = 'Token Secret';
      }
      $requirements['tmgmt_smartling'] = [
        'title' => t('Smartling'),
        'description' => t('Please set up missing settings for Smartling plugin at @page_url: @settings', [
          '@page_url' => Link::fromTextAndUrl(t('Smartling provider settings page'), Url::fromUri('internal:/admin/tmgmt/translators/manage/smartling', [
            'attributes' => [
              'target' => '_blank',
            ],
          ]))
            ->toString(),
          '@settings' => implode(', ', $missing_settings),
        ]),
        'severity' => REQUIREMENT_ERROR,
      ];
    }
  }
  return $requirements;
}