diff --git a/api/v3/Contacts/Correctnamecasesjob.php b/api/v3/Contacts/Correctnamecasesjob.php
index f203b0a..a3adc6b 100644
--- a/api/v3/Contacts/Correctnamecasesjob.php
+++ b/api/v3/Contacts/Correctnamecasesjob.php
@@ -58,7 +58,8 @@ function contacts_correctnamecasesjob_correct_name_case(&$aName) {
*/
function civicrm_api3_contacts_correctnamecasesjob($params) {
- $lastContactExaminedOffset = CRM_Core_BAO_Setting::getItem(CAPSCORRECT_EXTENSION_NAME, CAPSCORRECT_LAST_CONTACT_OFFSET);
+ $lastContactExaminedOffset = Civi::settings()->get(CAPSCORRECT_LAST_CONTACT_OFFSET);
+
// See if the returned value is NULL or negative
if ( $lastContactExaminedOffset === NULL || $lastContactExaminedOffset < 0 ) {
throw new API_Exception(/*errorMessage*/ 'Unable to complete scheduled job, the offset was not returned.', /*errorCode*/ 1);
@@ -106,14 +107,13 @@ function civicrm_api3_contacts_correctnamecasesjob($params) {
}
}
// Update the total contacts corrected setting value
- $totalContactsCorrected = CRM_Core_BAO_Setting::getItem(CAPSCORRECT_EXTENSION_NAME, CAPSCORRECT_TOTAL_CONTACTS_CORRECTED);
+ $totalContactsCorrected = Civi::settings()->get(CAPSCORRECT_TOTAL_CONTACTS_CORRECTED);
$totalContactsCorrected += $contactsCorrectedThisRun;
- CRM_Core_BAO_Setting::setItem($totalContactsCorrected, CAPSCORRECT_EXTENSION_NAME, CAPSCORRECT_TOTAL_CONTACTS_CORRECTED);
+ Civi::settings()->set(CAPSCORRECT_TOTAL_CONTACTS_CORRECTED, $totalContactsCorrected);
// Update the offset setting
$lastContactExaminedOffset += $getContactsApiResults['count'];
- CRM_Core_BAO_Setting::setItem($lastContactExaminedOffset, CAPSCORRECT_EXTENSION_NAME, CAPSCORRECT_LAST_CONTACT_OFFSET);
-
+ Civi::settings()->set(CAPSCORRECT_LAST_CONTACT_OFFSET, $lastContactExaminedOffset);
// Return values array
$apiReturnValues = array(
diff --git a/capscorrect.civix.php b/capscorrect.civix.php
index b22aa04..72f8fee 100644
--- a/capscorrect.civix.php
+++ b/capscorrect.civix.php
@@ -3,276 +3,205 @@
// AUTO-GENERATED FILE -- Civix may overwrite any changes made to this file
/**
- * (Delegated) Implementation of hook_civicrm_config
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_config
+ * The ExtensionUtil class provides small stubs for accessing resources of this
+ * extension.
*/
-function _capscorrect_civix_civicrm_config(&$config = NULL) {
- static $configured = FALSE;
- if ($configured) return;
- $configured = TRUE;
+class CRM_Capscorrect_ExtensionUtil {
+ const SHORT_NAME = 'capscorrect';
+ const LONG_NAME = 'uk.org.futurefirst.networks.capscorrect';
+ const CLASS_PREFIX = 'CRM_Capscorrect';
+
+ /**
+ * Translate a string using the extension's domain.
+ *
+ * If the extension doesn't have a specific translation
+ * for the string, fallback to the default translations.
+ *
+ * @param string $text
+ * Canonical message text (generally en_US).
+ * @param array $params
+ * @return string
+ * Translated text.
+ * @see ts
+ */
+ public static function ts($text, $params = []): string {
+ if (!array_key_exists('domain', $params)) {
+ $params['domain'] = [self::LONG_NAME, NULL];
+ }
+ return ts($text, $params);
+ }
- $template =& CRM_Core_Smarty::singleton();
+ /**
+ * Get the URL of a resource file (in this extension).
+ *
+ * @param string|NULL $file
+ * Ex: NULL.
+ * Ex: 'css/foo.css'.
+ * @return string
+ * Ex: 'http://example.org/sites/default/ext/org.example.foo'.
+ * Ex: 'http://example.org/sites/default/ext/org.example.foo/css/foo.css'.
+ */
+ public static function url($file = NULL): string {
+ if ($file === NULL) {
+ return rtrim(CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME), '/');
+ }
+ return CRM_Core_Resources::singleton()->getUrl(self::LONG_NAME, $file);
+ }
- $extRoot = dirname( __FILE__ ) . DIRECTORY_SEPARATOR;
- $extDir = $extRoot . 'templates';
+ /**
+ * Get the path of a resource file (in this extension).
+ *
+ * @param string|NULL $file
+ * Ex: NULL.
+ * Ex: 'css/foo.css'.
+ * @return string
+ * Ex: '/var/www/example.org/sites/default/ext/org.example.foo'.
+ * Ex: '/var/www/example.org/sites/default/ext/org.example.foo/css/foo.css'.
+ */
+ public static function path($file = NULL) {
+ // return CRM_Core_Resources::singleton()->getPath(self::LONG_NAME, $file);
+ return __DIR__ . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file));
+ }
- if ( is_array( $template->template_dir ) ) {
- array_unshift( $template->template_dir, $extDir );
- } else {
- $template->template_dir = array( $extDir, $template->template_dir );
+ /**
+ * Get the name of a class within this extension.
+ *
+ * @param string $suffix
+ * Ex: 'Page_HelloWorld' or 'Page\\HelloWorld'.
+ * @return string
+ * Ex: 'CRM_Foo_Page_HelloWorld'.
+ */
+ public static function findClass($suffix) {
+ return self::CLASS_PREFIX . '_' . str_replace('\\', '_', $suffix);
}
- $include_path = $extRoot . PATH_SEPARATOR . get_include_path( );
- set_include_path( $include_path );
}
-/**
- * (Delegated) Implementation of hook_civicrm_xmlMenu
- *
- * @param $files array(string)
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_xmlMenu
- */
-function _capscorrect_civix_civicrm_xmlMenu(&$files) {
- foreach (_capscorrect_civix_glob(__DIR__ . '/xml/Menu/*.xml') as $file) {
- $files[] = $file;
- }
-}
+use CRM_Capscorrect_ExtensionUtil as E;
-/**
- * Implementation of hook_civicrm_install
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_install
- */
-function _capscorrect_civix_civicrm_install() {
- _capscorrect_civix_civicrm_config();
- if ($upgrader = _capscorrect_civix_upgrader()) {
- return $upgrader->onInstall();
+function _capscorrect_civix_mixin_polyfill() {
+ if (!class_exists('CRM_Extension_MixInfo')) {
+ $polyfill = __DIR__ . '/mixin/polyfill.php';
+ (require $polyfill)(E::LONG_NAME, E::SHORT_NAME, E::path());
}
}
/**
- * Implementation of hook_civicrm_uninstall
+ * (Delegated) Implements hook_civicrm_config().
*
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
+ * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_config
*/
-function _capscorrect_civix_civicrm_uninstall() {
- _capscorrect_civix_civicrm_config();
- if ($upgrader = _capscorrect_civix_upgrader()) {
- return $upgrader->onUninstall();
+function _capscorrect_civix_civicrm_config($config = NULL) {
+ static $configured = FALSE;
+ if ($configured) {
+ return;
}
-}
+ $configured = TRUE;
-/**
- * (Delegated) Implementation of hook_civicrm_enable
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_enable
- */
-function _capscorrect_civix_civicrm_enable() {
- _capscorrect_civix_civicrm_config();
- if ($upgrader = _capscorrect_civix_upgrader()) {
- if (is_callable(array($upgrader, 'onEnable'))) {
- return $upgrader->onEnable();
- }
- }
+ $extRoot = __DIR__ . DIRECTORY_SEPARATOR;
+ $include_path = $extRoot . PATH_SEPARATOR . get_include_path();
+ set_include_path($include_path);
+ _capscorrect_civix_mixin_polyfill();
}
/**
- * (Delegated) Implementation of hook_civicrm_disable
+ * Implements hook_civicrm_install().
*
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
+ * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_install
*/
-function _capscorrect_civix_civicrm_disable() {
+function _capscorrect_civix_civicrm_install() {
_capscorrect_civix_civicrm_config();
- if ($upgrader = _capscorrect_civix_upgrader()) {
- if (is_callable(array($upgrader, 'onDisable'))) {
- return $upgrader->onDisable();
- }
- }
+ _capscorrect_civix_mixin_polyfill();
}
/**
- * (Delegated) Implementation of 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
+ * (Delegated) Implements hook_civicrm_enable().
*
- * @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
- * for 'enqueue', returns void
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
+ * @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_enable
*/
-function _capscorrect_civix_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
- if ($upgrader = _capscorrect_civix_upgrader()) {
- return $upgrader->onUpgrade($op, $queue);
- }
-}
-
-/**
- * @return CRM_Capscorrect_Upgrader
- */
-function _capscorrect_civix_upgrader() {
- if (!file_exists(__DIR__.'/CRM/Capscorrect/Upgrader.php')) {
- return NULL;
- } else {
- return CRM_Capscorrect_Upgrader_Base::instance();
- }
+function _capscorrect_civix_civicrm_enable(): void {
+ _capscorrect_civix_civicrm_config();
+ _capscorrect_civix_mixin_polyfill();
}
/**
- * Search directory tree for files which match a glob pattern
+ * Inserts a navigation menu item at a given place in the hierarchy.
*
- * Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
- * Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
+ * @param array $menu - menu hierarchy
+ * @param string $path - path to parent of this item, e.g. 'my_extension/submenu'
+ * 'Mailing', or 'Administer/System Settings'
+ * @param array $item - the item to insert (parent/child attributes will be
+ * filled for you)
*
- * @param $dir string, base dir
- * @param $pattern string, glob pattern, eg "*.txt"
- * @return array(string)
+ * @return bool
*/
-function _capscorrect_civix_find_files($dir, $pattern) {
- if (is_callable(array('CRM_Utils_File', 'findFiles'))) {
- return CRM_Utils_File::findFiles($dir, $pattern);
+function _capscorrect_civix_insert_navigation_menu(&$menu, $path, $item) {
+ // If we are done going down the path, insert menu
+ if (empty($path)) {
+ $menu[] = [
+ 'attributes' => array_merge([
+ 'label' => $item['name'] ?? NULL,
+ 'active' => 1,
+ ], $item),
+ ];
+ return TRUE;
}
-
- $todos = array($dir);
- $result = array();
- while (!empty($todos)) {
- $subdir = array_shift($todos);
- foreach (_capscorrect_civix_glob("$subdir/$pattern") as $match) {
- if (!is_dir($match)) {
- $result[] = $match;
- }
- }
- if ($dh = opendir($subdir)) {
- while (FALSE !== ($entry = readdir($dh))) {
- $path = $subdir . DIRECTORY_SEPARATOR . $entry;
- if ($entry{0} == '.') {
- } elseif (is_dir($path)) {
- $todos[] = $path;
+ else {
+ // Find an recurse into the next level down
+ $found = FALSE;
+ $path = explode('/', $path);
+ $first = array_shift($path);
+ foreach ($menu as $key => &$entry) {
+ if ($entry['attributes']['name'] == $first) {
+ if (!isset($entry['child'])) {
+ $entry['child'] = [];
}
+ $found = _capscorrect_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item);
}
- closedir($dh);
- }
- }
- return $result;
-}
-/**
- * (Delegated) Implementation of hook_civicrm_managed
- *
- * Find any *.mgd.php files, merge their content, and return.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
- */
-function _capscorrect_civix_civicrm_managed(&$entities) {
- $mgdFiles = _capscorrect_civix_find_files(__DIR__, '*.mgd.php');
- foreach ($mgdFiles as $file) {
- $es = include $file;
- foreach ($es as $e) {
- if (empty($e['module'])) {
- $e['module'] = 'uk.org.futurefirst.networks.capscorrect';
- }
- $entities[] = $e;
}
+ return $found;
}
}
/**
- * (Delegated) Implementation of hook_civicrm_caseTypes
- *
- * Find any and return any files matching "xml/case/*.xml"
- *
- * Note: This hook only runs in CiviCRM 4.4+.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
+ * (Delegated) Implements hook_civicrm_navigationMenu().
*/
-function _capscorrect_civix_civicrm_caseTypes(&$caseTypes) {
- if (!is_dir(__DIR__ . '/xml/case')) {
- return;
- }
-
- foreach (_capscorrect_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) {
- $name = preg_replace('/\.xml$/', '', basename($file));
- if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) {
- $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name));
- CRM_Core_Error::fatal($errorMessage);
- // throw new CRM_Core_Exception($errorMessage);
- }
- $caseTypes[$name] = array(
- 'module' => 'uk.org.futurefirst.networks.capscorrect',
- 'name' => $name,
- 'file' => $file,
- );
+function _capscorrect_civix_navigationMenu(&$nodes) {
+ if (!is_callable(['CRM_Core_BAO_Navigation', 'fixNavigationMenu'])) {
+ _capscorrect_civix_fixNavigationMenu($nodes);
}
}
/**
- * Glob wrapper which is guaranteed to return an array.
- *
- * The documentation for glob() says, "On some systems it is impossible to
- * distinguish between empty match and an error." Anecdotally, the return
- * result for an empty match is sometimes array() and sometimes FALSE.
- * This wrapper provides consistency.
- *
- * @link http://php.net/glob
- * @param string $pattern
- * @return array, possibly empty
+ * Given a navigation menu, generate navIDs for any items which are
+ * missing them.
*/
-function _capscorrect_civix_glob($pattern) {
- $result = glob($pattern);
- return is_array($result) ? $result : array();
+function _capscorrect_civix_fixNavigationMenu(&$nodes) {
+ $maxNavID = 1;
+ array_walk_recursive($nodes, function($item, $key) use (&$maxNavID) {
+ if ($key === 'navID') {
+ $maxNavID = max($maxNavID, $item);
+ }
+ });
+ _capscorrect_civix_fixNavigationMenuItems($nodes, $maxNavID, NULL);
}
-/**
- * Inserts a navigation menu item at a given place in the hierarchy
- *
- * $menu - menu hierarchy
- * $path - path where insertion should happen (ie. Administer/System Settings)
- * $item - menu you need to insert (parent/child attributes will be filled for you)
- * $parentId - used internally to recurse in the menu structure
- */
-function _capscorrect_civix_insert_navigation_menu(&$menu, $path, $item, $parentId = NULL) {
- static $navId;
-
- // If we are done going down the path, insert menu
- if (empty($path)) {
- if (!$navId) $navId = CRM_Core_DAO::singleValueQuery("SELECT max(id) FROM civicrm_navigation");
- $navId ++;
- $menu[$navId] = array (
- 'attributes' => array_merge($item, array(
- 'label' => CRM_Utils_Array::value('name', $item),
- 'active' => 1,
- 'parentID' => $parentId,
- 'navID' => $navId,
- ))
- );
- return true;
- } else {
- // Find an recurse into the next level down
- $found = false;
- $path = explode('/', $path);
- $first = array_shift($path);
- foreach ($menu as $key => &$entry) {
- if ($entry['attributes']['name'] == $first) {
- if (!$entry['child']) $entry['child'] = array();
- $found = _capscorrect_civix_insert_navigation_menu($entry['child'], implode('/', $path), $item, $key);
- }
+function _capscorrect_civix_fixNavigationMenuItems(&$nodes, &$maxNavID, $parentID) {
+ $origKeys = array_keys($nodes);
+ foreach ($origKeys as $origKey) {
+ if (!isset($nodes[$origKey]['attributes']['parentID']) && $parentID !== NULL) {
+ $nodes[$origKey]['attributes']['parentID'] = $parentID;
+ }
+ // If no navID, then assign navID and fix key.
+ if (!isset($nodes[$origKey]['attributes']['navID'])) {
+ $newKey = ++$maxNavID;
+ $nodes[$origKey]['attributes']['navID'] = $newKey;
+ $nodes[$newKey] = $nodes[$origKey];
+ unset($nodes[$origKey]);
+ $origKey = $newKey;
+ }
+ if (isset($nodes[$origKey]['child']) && is_array($nodes[$origKey]['child'])) {
+ _capscorrect_civix_fixNavigationMenuItems($nodes[$origKey]['child'], $maxNavID, $nodes[$origKey]['attributes']['navID']);
}
- return $found;
}
}
-
-/**
- * (Delegated) Implementation of hook_civicrm_alterSettingsFolders
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
- */
-function _capscorrect_civix_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
- static $configured = FALSE;
- if ($configured) return;
- $configured = TRUE;
-
- $settingsDir = __DIR__ . DIRECTORY_SEPARATOR . 'settings';
- if(is_dir($settingsDir) && !in_array($settingsDir, $metaDataFolders)) {
- $metaDataFolders[] = $settingsDir;
- }
-}
\ No newline at end of file
diff --git a/capscorrect.php b/capscorrect.php
index 576e503..c1bd209 100644
--- a/capscorrect.php
+++ b/capscorrect.php
@@ -1,10 +1,9 @@
set(CAPSCORRECT_LAST_CONTACT_OFFSET, 0);
+ Civi::settings()->set(CAPSCORRECT_TOTAL_CONTACTS_CORRECTED, 0);
return _capscorrect_civix_civicrm_install();
}
-/**
- * Implementation of hook_civicrm_uninstall
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_uninstall
- */
-function capscorrect_civicrm_uninstall() {
- return _capscorrect_civix_civicrm_uninstall();
-}
-
/**
* Implementation of hook_civicrm_enable
*
@@ -63,61 +42,3 @@ function capscorrect_civicrm_uninstall() {
function capscorrect_civicrm_enable() {
return _capscorrect_civix_civicrm_enable();
}
-
-/**
- * Implementation of hook_civicrm_disable
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_disable
- */
-function capscorrect_civicrm_disable() {
- return _capscorrect_civix_civicrm_disable();
-}
-
-/**
- * Implementation of 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 http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_upgrade
- */
-function capscorrect_civicrm_upgrade($op, CRM_Queue_Queue $queue = NULL) {
- return _capscorrect_civix_civicrm_upgrade($op, $queue);
-}
-
-/**
- * Implementation of hook_civicrm_managed
- *
- * Generate a list of entities to create/deactivate/delete when this module
- * is installed, disabled, uninstalled.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_managed
- */
-function capscorrect_civicrm_managed(&$entities) {
- return _capscorrect_civix_civicrm_managed($entities);
-}
-
-/**
- * Implementation of hook_civicrm_caseTypes
- *
- * Generate a list of case-types
- *
- * Note: This hook only runs in CiviCRM 4.4+.
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
- */
-function capscorrect_civicrm_caseTypes(&$caseTypes) {
- _capscorrect_civix_civicrm_caseTypes($caseTypes);
-}
-
-/**
- * Implementation of hook_civicrm_alterSettingsFolders
- *
- * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_alterSettingsFolders
- */
-function capscorrect_civicrm_alterSettingsFolders(&$metaDataFolders = NULL) {
- _capscorrect_civix_civicrm_alterSettingsFolders($metaDataFolders);
-}
diff --git a/info.xml b/info.xml
index efec9de..508efc0 100644
--- a/info.xml
+++ b/info.xml
@@ -17,12 +17,17 @@
1.1
stable
- 4.4
- 4.5
- 4.6
+ 5.27
The number of contacts scanned each day can be set in Civi's scheduled job settings page.
CRM/Capscorrect
+ 23.02.1
+
+ mgd-php@1.0.0
+
+
+
+
diff --git a/mixin/mgd-php@1.0.0.mixin.php b/mixin/mgd-php@1.0.0.mixin.php
new file mode 100644
index 0000000..39d45b1
--- /dev/null
+++ b/mixin/mgd-php@1.0.0.mixin.php
@@ -0,0 +1,42 @@
+addListener('hook_civicrm_managed', function ($event) use ($mixInfo) {
+ // When deactivating on a polyfill/pre-mixin system, listeners may not cleanup automatically.
+ if (!$mixInfo->isActive()) {
+ return;
+ }
+
+ $mgdFiles = CRM_Utils_File::findFiles($mixInfo->getPath(), '*.mgd.php');
+ sort($mgdFiles);
+ foreach ($mgdFiles as $file) {
+ $es = include $file;
+ foreach ($es as $e) {
+ if (empty($e['module'])) {
+ $e['module'] = $mixInfo->longName;
+ }
+ if (empty($e['params']['version'])) {
+ $e['params']['version'] = '3';
+ }
+ $event->entities[] = $e;
+ }
+ }
+ });
+
+};
diff --git a/mixin/polyfill.php b/mixin/polyfill.php
new file mode 100644
index 0000000..17ba1df
--- /dev/null
+++ b/mixin/polyfill.php
@@ -0,0 +1,101 @@
+')) {
+ $mixinVers[$name] = $ver;
+ }
+ }
+ $mixins = [];
+ foreach ($mixinVers as $name => $ver) {
+ $mixins[] = "$name@$ver";
+ }
+
+ // Imitate CRM_Extension_MixInfo.
+ $mixInfo = new class() {
+
+ /**
+ * @var string
+ */
+ public $longName;
+
+ /**
+ * @var string
+ */
+ public $shortName;
+
+ public $_basePath;
+
+ public function getPath($file = NULL) {
+ return $this->_basePath . ($file === NULL ? '' : (DIRECTORY_SEPARATOR . $file));
+ }
+
+ public function isActive() {
+ return \CRM_Extension_System::singleton()->getMapper()->isActiveModule($this->shortName);
+ }
+
+ };
+ $mixInfo->longName = $longName;
+ $mixInfo->shortName = $shortName;
+ $mixInfo->_basePath = $basePath;
+
+ // Imitate CRM_Extension_BootCache.
+ $bootCache = new class() {
+
+ public function define($name, $callback) {
+ $envId = \CRM_Core_Config_Runtime::getId();
+ $oldExtCachePath = \Civi::paths()->getPath("[civicrm.compile]/CachedExtLoader.{$envId}.php");
+ $stat = stat($oldExtCachePath);
+ $file = Civi::paths()->getPath('[civicrm.compile]/CachedMixin.' . md5($name . ($stat['mtime'] ?? 0)) . '.php');
+ if (file_exists($file)) {
+ return include $file;
+ }
+ else {
+ $data = $callback();
+ file_put_contents($file, '<' . "?php\nreturn " . var_export($data, 1) . ';');
+ return $data;
+ }
+ }
+
+ };
+
+ // Imitate CRM_Extension_MixinLoader::run()
+ // Parse all live mixins before trying to scan any classes.
+ global $_CIVIX_MIXIN_POLYFILL;
+ foreach ($mixins as $mixin) {
+ // If the exact same mixin is defined by multiple exts, just use the first one.
+ if (!isset($_CIVIX_MIXIN_POLYFILL[$mixin])) {
+ $_CIVIX_MIXIN_POLYFILL[$mixin] = include_once $basePath . '/mixin/' . $mixin . '.mixin.php';
+ }
+ }
+ foreach ($mixins as $mixin) {
+ // If there's trickery about installs/uninstalls/resets, then we may need to register a second time.
+ if (!isset(\Civi::$statics[$longName][$mixin])) {
+ \Civi::$statics[$longName][$mixin] = 1;
+ $func = $_CIVIX_MIXIN_POLYFILL[$mixin];
+ $func($mixInfo, $bootCache);
+ }
+ }
+};