Skip to content

Commit

Permalink
Merge pull request #19 from monishdeb/civix_upgrade
Browse files Browse the repository at this point in the history
Run Civix upgrade
  • Loading branch information
adixon authored Oct 11, 2023
2 parents 2deb5cb + 9c32c62 commit 6f4c635
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 211 deletions.
41 changes: 6 additions & 35 deletions contributionrecur.civix.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,40 +79,22 @@ public static function findClass($suffix) {

use CRM_Contributionrecur_ExtensionUtil as E;

function _contributionrecur_civix_mixin_polyfill() {
if (!class_exists('CRM_Extension_MixInfo')) {
$polyfill = __DIR__ . '/mixin/polyfill.php';
(require $polyfill)(E::LONG_NAME, E::SHORT_NAME, E::path());
}
}

/**
* (Delegated) Implements hook_civicrm_config().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config
*/
function _contributionrecur_civix_civicrm_config(&$config = NULL) {
function _contributionrecur_civix_civicrm_config($config = NULL) {
static $configured = FALSE;
if ($configured) {
return;
}
$configured = TRUE;

$template = CRM_Core_Smarty::singleton();

$extRoot = __DIR__ . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';

if (is_array($template->template_dir)) {
array_unshift($template->template_dir, $extDir);
}
else {
$template->template_dir = [$extDir, $template->template_dir];
}

$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
set_include_path($include_path);
_contributionrecur_civix_mixin_polyfill();
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
}

/**
Expand All @@ -122,7 +104,7 @@ function _contributionrecur_civix_civicrm_config(&$config = NULL) {
*/
function _contributionrecur_civix_civicrm_install() {
_contributionrecur_civix_civicrm_config();
_contributionrecur_civix_mixin_polyfill();
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
}

/**
Expand All @@ -132,7 +114,7 @@ function _contributionrecur_civix_civicrm_install() {
*/
function _contributionrecur_civix_civicrm_enable(): void {
_contributionrecur_civix_civicrm_config();
_contributionrecur_civix_mixin_polyfill();
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
}

/**
Expand All @@ -151,8 +133,8 @@ function _contributionrecur_civix_insert_navigation_menu(&$menu, $path, $item) {
if (empty($path)) {
$menu[] = [
'attributes' => array_merge([
'label' => CRM_Utils_Array::value('name', $item),
'active' => 1,
'label' => $item['name'] ?? NULL,
'active' => 1,
], $item),
];
return TRUE;
Expand Down Expand Up @@ -216,14 +198,3 @@ function _contributionrecur_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $p
}
}
}

/**
* (Delegated) Implements hook_civicrm_entityTypes().
*
* Find any *.entityType.php files, merge their content, and return.
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function _contributionrecur_civix_civicrm_entityTypes(&$entityTypes) {
$entityTypes = array_merge($entityTypes, []);
}
1 change: 0 additions & 1 deletion contributionrecur.php
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,6 @@ function contributionrecur_civicrm_container(ContainerBuilder $container) {
)->setPublic(TRUE);
}


/*
* contributionrecur_getFields()
*
Expand Down
4 changes: 3 additions & 1 deletion info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
<comments>Incubated since 2014</comments>
<civix>
<namespace>CRM/Contributionrecur</namespace>
<format>22.12.1</format>
<format>23.02.1</format>
</civix>
<mixins>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
<mixin>[email protected]</mixin>
</mixins>
<classloader>
<psr0 prefix="CRM_" path="."/>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
</extension>
31 changes: 0 additions & 31 deletions mixin/[email protected]

This file was deleted.

42 changes: 0 additions & 42 deletions mixin/[email protected]

This file was deleted.

101 changes: 0 additions & 101 deletions mixin/polyfill.php

This file was deleted.

51 changes: 51 additions & 0 deletions mixin/[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* Auto-register "templates/" folder.
*
* @mixinName smarty-v2
* @mixinVersion 1.0.1
* @since 5.59
*
* @param CRM_Extension_MixInfo $mixInfo
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
* @param \CRM_Extension_BootCache $bootCache
* On newer deployments, this will be an instance of MixInfo. On older deployments, Civix may polyfill with a work-a-like.
*/
return function ($mixInfo, $bootCache) {
$dir = $mixInfo->getPath('templates');
if (!file_exists($dir)) {
return;
}

$register = function() use ($dir) {
// This implementation has a theoretical edge-case bug on older versions of CiviCRM where a template could
// be registered more than once.
CRM_Core_Smarty::singleton()->addTemplateDir($dir);
};

// Let's figure out what environment we're in -- so that we know the best way to call $register().

if (!empty($GLOBALS['_CIVIX_MIXIN_POLYFILL'])) {
// Polyfill Loader (v<=5.45): We're already in the middle of firing `hook_config`.
if ($mixInfo->isActive()) {
$register();
}
return;
}

if (CRM_Extension_System::singleton()->getManager()->extensionIsBeingInstalledOrEnabled($mixInfo->longName)) {
// New Install, Standard Loader: The extension has just been enabled, and we're now setting it up.
// System has already booted. New templates may be needed for upcoming installation steps.
$register();
return;
}

// Typical Pageview, Standard Loader: Defer the actual registration for a moment -- to ensure that Smarty is online.
\Civi::dispatcher()->addListener('hook_civicrm_config', function() use ($mixInfo, $register) {
if ($mixInfo->isActive()) {
$register();
}
});

};

0 comments on commit 6f4c635

Please sign in to comment.