Commit 078ea07d authored by mattwire's avatar mattwire
Browse files

Update mjwshared requirement to 0.9

parent df2019db
......@@ -19,36 +19,79 @@ class CRM_AuthorizeNet_Check {
/**
* @var string
*/
const MIN_VERSION_MJWSHARED = '0.8';
const MIN_VERSION_MJWSHARED = '0.9';
public static function checkRequirements(&$messages) {
self::checkExtensionMjwshared($messages);
}
/**
* @param array $messages
*
* @throws \CiviCRM_API3_Exception
*/
private static function checkExtensionMjwshared(&$messages) {
// mjwshared: required. Requires min version
$extensionName = 'mjwshared';
$extensions = civicrm_api3('Extension', 'get', [
'full_name' => "mjwshared",
'full_name' => $extensionName,
]);
if (empty($extensions['id']) || ($extensions['values'][$extensions['id']]['status'] !== 'installed')) {
$messages[] = new CRM_Utils_Check_Message(
E::SHORT_NAME . '_requirements',
E::ts('The %1 extension requires the mjwshared extension which is not installed (https://lab.civicrm.org/extensions/mjwshared).', [1 => E::SHORT_NAME]),
E::ts('%1: Missing Requirements', [1 => E::SHORT_NAME]),
$message = new CRM_Utils_Check_Message(
__FUNCTION__ . E::SHORT_NAME . '_requirements',
E::ts('The <em>%1</em> extension requires the <em>Payment Shared</em> extension which is not installed. See <a href="%2" target="_blank">details</a> for more information.',
[
1 => ucfirst(E::SHORT_NAME),
2 => 'https://civicrm.org/extensions/mjwshared',
]
),
E::ts('%1: Missing Requirements', [1 => ucfirst(E::SHORT_NAME)]),
\Psr\Log\LogLevel::ERROR,
'fa-money'
);
$message->addAction(
E::ts('Install now'),
NULL,
'href',
['path' => 'civicrm/admin/extensions', 'query' => ['action' => 'update', 'id' => $extensionName, 'key' => $extensionName]]
);
$messages[] = $message;
return;
}
if ($extensions['values'][$extensions['id']]['status'] === 'installed') {
self::requireExtensionMinVersion($messages, $extensionName, self::MIN_VERSION_MJWSHARED, $extensions['values'][$extensions['id']]['version']);
}
}
if (version_compare($extensions['values'][$extensions['id']]['version'], CRM_AuthorizeNet_Check::MIN_VERSION_MJWSHARED) === -1) {
$messages[] = new CRM_Utils_Check_Message(
E::SHORT_NAME . '_requirements',
E::ts('The %1 extension requires the mjwshared extension version %2 or greater but your system has version %3.',
/**
* @param array $messages
* @param string $extensionName
* @param string $minVersion
* @param string $actualVersion
*/
private static function requireExtensionMinVersion(&$messages, $extensionName, $minVersion, $actualVersion) {
if (version_compare($actualVersion, $minVersion) === -1) {
$message = new CRM_Utils_Check_Message(
__FUNCTION__ . $extensionName . E::SHORT_NAME . '_requirements',
E::ts('The %1 extension requires the %2 extension version %3 or greater but your system has version %4.',
[
1 => E::SHORT_NAME,
2 => CRM_AuthorizeNet_Check::MIN_VERSION_MJWSHARED,
3 => $extensions['values'][$extensions['id']]['version']
1 => ucfirst(E::SHORT_NAME),
2 => $extensionName,
3 => $minVersion,
4 => $actualVersion
]),
E::ts('%1: Missing Requirements', [1 => E::SHORT_NAME]),
E::ts('%1: Missing Requirements', [1 => ucfirst(E::SHORT_NAME)]),
\Psr\Log\LogLevel::ERROR,
'fa-money'
);
$message->addAction(
E::ts('Upgrade now'),
NULL,
'href',
['path' => 'civicrm/admin/extensions', 'query' => ['action' => 'update', 'id' => $extensionName, 'key' => $extensionName]]
);
$messages[] = $message;
}
}
......
......@@ -128,6 +128,9 @@ function authnetecheck_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
* Implements hook_civicrm_check().
*/
function authnetecheck_civicrm_check(&$messages) {
CRM_AuthorizeNet_Webhook::check($messages);
CRM_AuthorizeNet_Check::checkRequirements($messages);
// If we didn't install mjwshared yet check requirements but don't crash when checking webhooks
if (trait_exists('CRM_Mjwshared_WebhookTrait')) {
CRM_AuthorizeNet_Webhook::check($messages);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment