Commit 44e11463 authored by mattwire's avatar mattwire

Add checks and support for minifier extension

parent d1f72da6
......@@ -32,6 +32,39 @@ class CRM_Mjwshared_Check {
'fa-money'
);
}
$extensions = civicrm_api3('Extension', 'get', [
'full_name' => 'minifier',
]);
if (empty($extensions['id']) || ($extensions['values'][$extensions['id']]['status'] !== 'installed')) {
$messages[] = new CRM_Utils_Check_Message(
'mjwshared_recommended',
E::ts('It is recommended that you install the minifier extension from https://lab.civicrm.org/extensions/minifier'),
E::ts('Recommended Extension: minifier'),
\Psr\Log\LogLevel::NOTICE,
'fa-lightbulb-o'
);
}
// Only on Drupal - do we have webform_civicrm installed?
if (function_exists('module_exists')) {
$extensions = civicrm_api3('Extension', 'get', [
'full_name' => 'contributiontransactlegacy',
]);
if (module_exists('webform_civicrm') && (empty($extensions['id']) || ($extensions['values'][$extensions['id']]['status'] !== 'installed'))) {
$messages[] = new CRM_Utils_Check_Message(
'contributiontransactlegacy_recommended',
E::ts('If you are using Drupal webform_civicrm to accept payments you should install the <strong>contributiontransactlegacy</strong> from https://github.com/mjwconsult/civicrm-contributiontransactlegacy'),
E::ts('Recommended Extension: contributiontransactlegacy'),
\Psr\Log\LogLevel::NOTICE,
'fa-lightbulb-o'
);
}
}
}
}
......@@ -8,6 +8,12 @@ Where:
* minor: Breaking change in some circumstances, or a new feature. Read carefully and make sure you understand the impact of the change.
* incremental: A "safe" change / improvement. Should *always* be safe to upgrade.
## Release 0.7
* Implement buildAsset hook so that assets can be loaded via AssetBuilder without the [minifier](https://lab.civicrm.org/extensions/minifier) extension being available.
* Recommend minifier extension (and implement a dummy buildAsset hook so extensions using buildAsset for the minifier will still work without it).
* Recommend contributiontransactlegacy extension if drupal webform_civicrm is enabled.
## Release 0.6
* Improve updateContributionRefund() function to handle new `order_reference` field and use `Payment.create` API.
......
......@@ -10,12 +10,13 @@
</maintainer>
<urls>
<url desc="Main Extension Page">https://lab.civicrm.org/extensions/mjwshared</url>
<url desc="Support">https://www.mjwconsult.co.uk</url>
<url desc="Support">https://www.mjwconsult.co.uk/support</url>
<url desc="Release Notes">https://lab.civicrm.org/extensions/mjwshared/blob/0.7/docs/release/release_notes.md</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2019-12-28</releaseDate>
<version>0.6</version>
<develStage>stable</develStage>
<releaseDate>2020-02-10</releaseDate>
<version>0.7beta1</version>
<develStage>beta</develStage>
<compatibility>
<ver>5.19</ver>
</compatibility>
......
......@@ -13,6 +13,13 @@ use CRM_Mjwshared_ExtensionUtil as E;
*/
function mjwshared_civicrm_config(&$config) {
_mjwshared_civix_civicrm_config($config);
if (isset(Civi::$statics[__FUNCTION__])) { return; }
Civi::$statics[__FUNCTION__] = 1;
// Add listeners for CiviCRM hooks that might need altering by other scripts
// Make sure this runs after everything else but before minifier
Civi::dispatcher()->addListener('hook_civicrm_buildAsset', 'mjwshared_symfony_civicrm_buildAsset', -990);
}
/**
......@@ -157,3 +164,20 @@ function mjwshared_civicrm_buildForm($formName, &$form) {
function mjwshared_civicrm_check(&$messages) {
CRM_Mjwshared_Check::checkRequirements($messages);
}
/**
* @param \Civi\Core\Event\GenericHookEvent $event
* @param $hook
*
* @throws \CiviCRM_API3_Exception
*/
function mjwshared_symfony_civicrm_buildAsset($event, $hook) {
$extensions = civicrm_api3('Extension', 'get', [
'full_name' => "minifier",
]);
if (empty($extensions['id']) || ($extensions['values'][$extensions['id']]['status'] !== 'installed')) {
if (empty($event->content) && !empty($event->params['path'])) {
$event->content = file_get_contents($event->params['path']);
}
}
}
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