Skip to content

Commit

Permalink
CIVIBLD-287 [AUTO] civix upgraded
Browse files Browse the repository at this point in the history
Files changed:
M	civiquickbooks.civix.php
M	civiquickbooks.php
M	info.xml
A	mixin/[email protected]
  • Loading branch information
JoeMurray committed Aug 8, 2023
1 parent b733f23 commit e490e3f
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 28 deletions.
20 changes: 2 additions & 18 deletions civiquickbooks.civix.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,6 @@ function _civiquickbooks_civix_civicrm_config($config = NULL) {
$configured = TRUE;

$extRoot = __DIR__ . DIRECTORY_SEPARATOR;
$extDir = $extRoot . 'templates';
if (file_exists($extDir)) {
CRM_Core_Smarty::singleton()->addTemplateDir($extDir);
}

$include_path = $extRoot . PATH_SEPARATOR . get_include_path();
set_include_path($include_path);
_civiquickbooks_civix_mixin_polyfill();
Expand Down Expand Up @@ -145,8 +140,8 @@ function _civiquickbooks_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 @@ -210,14 +205,3 @@ function _civiquickbooks_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $pare
}
}
}

/**
* (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 _civiquickbooks_civix_civicrm_entityTypes(&$entityTypes) {
$entityTypes = array_merge($entityTypes, []);
}
9 changes: 0 additions & 9 deletions civiquickbooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,3 @@ function civiquickbooks_civicrm_pageRun(&$page) {
]);
}
}

/**
* Implements hook_civicrm_entityTypes().
*
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
*/
function civiquickbooks_civicrm_entityTypes(&$entityTypes) {
_civiquickbooks_civix_civicrm_entityTypes($entityTypes);
}
4 changes: 3 additions & 1 deletion info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
<comments>Development and support for this Extension is funded solely by Agileware and CiviCRM community contributions. Agileware does not receive any funding at all for this Extension from the CiviCRM Partner program or CiviCRM LLC. Agileware welcome any funding to help continue paying Agileware staff to continue contributing to the CiviCRM community and Extensions. You can donate to Agileware using https://www.paypal.me/agileware</comments>
<civix>
<namespace>CRM/Civiquickbooks</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>
<mixin>[email protected]</mixin>
</mixins>
<classloader>
<psr0 prefix="CRM_" path="."/>
<psr4 prefix="Civi\" path="Civi"/>
</classloader>
<upgrader>CRM_Civiquickbooks_Upgrader</upgrader>
</extension>
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 e490e3f

Please sign in to comment.