Skip to content

Commit

Permalink
Merge pull request #14 from eileenmcnaughton/master
Browse files Browse the repository at this point in the history
Civix upgrade (supports Smarty3)
  • Loading branch information
eileenmcnaughton authored Nov 2, 2023
2 parents f056abd + dcff917 commit 5a08116
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 165 deletions.
10 changes: 7 additions & 3 deletions info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@
<url desc="Support">http://FIXME</url>
<url desc="Licensing">http://www.gnu.org/licenses/agpl-3.0.html</url>
</urls>
<releaseDate>2022-09-22</releaseDate>
<version>1.1</version>
<releaseDate>2023-11-02</releaseDate>
<version>1.2</version>
<develStage>stable</develStage>
<compatibility>
<ver>5.51</ver>
</compatibility>
<comments>This extension allows you to define a second read only database connection for load balancing. Operations that do not need to write to the database will use it</comments>
<civix>
<namespace>CRM/Rpow</namespace>
<format>22.05.2</format>
<format>23.02.1</format>
</civix>
<classloader>
<psr0 prefix="CRM_" path="."/>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
</extension>
122 changes: 7 additions & 115 deletions rpow.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_Rpow_ExtensionUtil as E;

function _rpow_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 _rpow_civix_civicrm_config(&$config = NULL) {
function _rpow_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);
_rpow_civix_mixin_polyfill();
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
}

/**
Expand All @@ -122,96 +104,17 @@ function _rpow_civix_civicrm_config(&$config = NULL) {
*/
function _rpow_civix_civicrm_install() {
_rpow_civix_civicrm_config();
if ($upgrader = _rpow_civix_upgrader()) {
$upgrader->onInstall();
}
_rpow_civix_mixin_polyfill();
}

/**
* Implements hook_civicrm_postInstall().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_postInstall
*/
function _rpow_civix_civicrm_postInstall() {
_rpow_civix_civicrm_config();
if ($upgrader = _rpow_civix_upgrader()) {
if (is_callable([$upgrader, 'onPostInstall'])) {
$upgrader->onPostInstall();
}
}
}

/**
* Implements hook_civicrm_uninstall().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_uninstall
*/
function _rpow_civix_civicrm_uninstall() {
_rpow_civix_civicrm_config();
if ($upgrader = _rpow_civix_upgrader()) {
$upgrader->onUninstall();
}
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
}

/**
* (Delegated) Implements hook_civicrm_enable().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
*/
function _rpow_civix_civicrm_enable() {
_rpow_civix_civicrm_config();
if ($upgrader = _rpow_civix_upgrader()) {
if (is_callable([$upgrader, 'onEnable'])) {
$upgrader->onEnable();
}
}
_rpow_civix_mixin_polyfill();
}

/**
* (Delegated) Implements hook_civicrm_disable().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_disable
* @return mixed
*/
function _rpow_civix_civicrm_disable() {
function _rpow_civix_civicrm_enable(): void {
_rpow_civix_civicrm_config();
if ($upgrader = _rpow_civix_upgrader()) {
if (is_callable([$upgrader, 'onDisable'])) {
$upgrader->onDisable();
}
}
}

/**
* (Delegated) Implements hook_civicrm_upgrade().
*
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
*
* @return mixed
* based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
* for 'enqueue', returns void
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
*/
function _rpow_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
if ($upgrader = _rpow_civix_upgrader()) {
return $upgrader->onUpgrade($op, $queue);
}
}

/**
* @return CRM_Rpow_Upgrader
*/
function _rpow_civix_upgrader() {
if (!file_exists(__DIR__ . '/CRM/Rpow/Upgrader.php')) {
return NULL;
}
else {
return CRM_Rpow_Upgrader_Base::instance();
}
// Based on <compatibility>, this does not currently require mixin/polyfill.php.
}

/**
Expand All @@ -230,8 +133,8 @@ function _rpow_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 @@ -295,14 +198,3 @@ function _rpow_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $parentID) {
}
}
}

/**
* (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 _rpow_civix_civicrm_entityTypes(&$entityTypes) {
$entityTypes = array_merge($entityTypes, []);
}
47 changes: 0 additions & 47 deletions rpow.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,24 +123,6 @@ function rpow_civicrm_install() {
_rpow_civix_civicrm_install();
}

/**
* Implements hook_civicrm_postInstall().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_postInstall
*/
function rpow_civicrm_postInstall() {
_rpow_civix_civicrm_postInstall();
}

/**
* Implements hook_civicrm_uninstall().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
*/
function rpow_civicrm_uninstall() {
_rpow_civix_civicrm_uninstall();
}

/**
* Implements hook_civicrm_enable().
*
Expand All @@ -150,35 +132,6 @@ function rpow_civicrm_enable() {
_rpow_civix_civicrm_enable();
}

/**
* Implements hook_civicrm_disable().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
*/
function rpow_civicrm_disable() {
_rpow_civix_civicrm_disable();
}

/**
* Implements hook_civicrm_upgrade().
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
*/
function rpow_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
return _rpow_civix_civicrm_upgrade($op, $queue);
}

/**
* Implements hook_civicrm_entityTypes().
*
* Declare entity types provided by this module.
*
* @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_entityTypes
*/
function rpow_civicrm_entityTypes(&$entityTypes) {
_rpow_civix_civicrm_entityTypes($entityTypes);
}

// --- Functions below this ship commented out. Uncomment as required. ---

/**
Expand Down

0 comments on commit 5a08116

Please sign in to comment.