marketo_ma-8.x-2.x-dev/modules/marketo_ma_legacy_client/marketo_ma_legacy_client.install
modules/marketo_ma_legacy_client/marketo_ma_legacy_client.install
<?php
/**
* @file
* Install hooks for Marketo MA Legacy Client module.
*/
use Drupal\Core\Url;
/**
* Implements hook_requirements().
*/
function marketo_ma_legacy_client_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
if (!class_exists('\CSD\Marketo\Client')) {
// The composer library is missing.
$requirements['marketo_ma_legacy_marketo_client'] = [
'description' => t(
"The Marketo REST legacy api client is required
for the Marketo MA module. Please read the module's readme for
installation instructions."
),
'title' => t('Marketo Legacy REST client'),
'severity' => REQUIREMENT_ERROR,
'value' => t('Not found'),
];
}
else {
/**
* @var \Drupal\marketo_ma\Service\MarketoMaApiClientInterface $marketo_client
*/
$marketo_client = \Drupal::service('marketo_ma.api_client');
if (!$marketo_client->canConnect()) {
// Some required configuration is missing for the Marketo API.
$requirements['marketo_ma_rest_configuration'] = [
'description' => t(
'The Marketo Legacy REST API was chosen for connection method but some <a href=":link">configuration</a> seems to be missing or invalid.',
[
':link' => Url::fromRoute('marketo_ma.settings')->toString(),
]
),
'title' => t('Marketo MA configuration.'),
'severity' => REQUIREMENT_ERROR,
'value' => t('Configuration incomplete.'),
];
}
}
if (version_compare(PHP_VERSION, '8.0.0') >= 0) {
$requirements['marketo_ma_legacy_client_php_version'] = [
'description' => t('Legacy Guzzle does not work with PHP 8.'),
'title' => t('Marketo MA Legacy PHP Version.'),
'severity' => REQUIREMENT_ERROR,
'value' => t('Invalid PHP version.'),
];
}
}
return $requirements;
}
