38 lines
870 B
PHP
38 lines
870 B
PHP
<?php
|
|
|
|
use GuzzleHttp\Exception\ClientException;
|
|
|
|
/**
|
|
* @file
|
|
* Install, update and uninstall functions for the Etherpad API module.
|
|
*/
|
|
|
|
/**
|
|
* Implements hook_requirements().
|
|
*/
|
|
function etherpad_api_requirements($phase) {
|
|
$requirements = [];
|
|
|
|
// Preveri ali api deluje
|
|
if ($phase == 'runtime') {
|
|
$client = Drupal::service('etherpad_api.client');
|
|
|
|
try {
|
|
$client->checkToken();
|
|
} catch (ClientException $exception) {
|
|
$value = $exception->getCode();
|
|
$msg = $exception->getMessage();
|
|
$requirements['etherpad_api_status'] = [
|
|
'title' => t('Etherpad API status'),
|
|
'value' => t('Etherpad API not accessible (@code: @msg)', [
|
|
'@code' => $exception->getCode(),
|
|
'@msg' => $exception->getMessage()
|
|
]),
|
|
'severity' => REQUIREMENT_ERROR,
|
|
];
|
|
}
|
|
}
|
|
|
|
return $requirements;
|
|
}
|