diff --git a/CRM/Banking/BAO/BankTransaction.php b/CRM/Banking/BAO/BankTransaction.php
index 81ab5add..b77dc158 100755
--- a/CRM/Banking/BAO/BankTransaction.php
+++ b/CRM/Banking/BAO/BankTransaction.php
@@ -282,7 +282,7 @@ public function get($k = NULL, $v = NULL) {
public static function findUnprocessedIDs($max_count) {
$results = [];
$maxcount = (int) $max_count;
- $status_id_new = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'new');
+ $status_id_new = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'new');
$sql_query = "SELECT `id` AS txid FROM `civicrm_bank_tx` WHERE `status_id` = '$status_id_new' ORDER BY `value_date` ASC, `id` ASC LIMIT $maxcount";
$query_results = CRM_Core_DAO::executeQuery($sql_query);
while ($query_results->fetch()) {
diff --git a/CRM/Banking/Helpers/OptionValue.php b/CRM/Banking/Helpers/OptionValue.php
index 22a56ac8..8d814431 100755
--- a/CRM/Banking/Helpers/OptionValue.php
+++ b/CRM/Banking/Helpers/OptionValue.php
@@ -16,140 +16,144 @@
declare(strict_types = 1);
-/**
- * looks up an option group ID
- *
- * the implementation is probably not optimal, but it'll do for the moment
- *
- */
-function banking_helper_optiongroupid_by_name($group_name): int {
- $result = civicrm_api3('OptionGroup', 'get', ['name' => $group_name]);
-
- if (empty($result['id'])) {
- Civi::log()->debug("org.project60.banking: Couldn't find option group '{$group_name}'!");
- return 0;
- }
- else {
- return (int) $result['id'];
- }
-}
+class CRM_Banking_Helpers_OptionValue {
-/**
- * looks up an option value
- *
- * the implementation is probably not optimal, but it'll do for the moment
- *
- */
-function banking_helper_optionvalueid_by_name($group_id, $value_name): int {
- $result = civicrm_api3('OptionValue', 'get', [
- 'name' => $value_name,
- 'option_group_id' => $group_id,
- ]);
-
- if (empty($result['id'])) {
- Civi::log()->debug("org.project60.banking: Couldn't find option value '{$value_name}'!");
- return 0;
- }
- else {
- return (int) $result['id'];
- }
-}
+ /**
+ * looks up an option group ID
+ *
+ * the implementation is probably not optimal, but it'll do for the moment
+ *
+ */
+ public static function banking_helper_optiongroupid_by_name($group_name): int {
+ $result = civicrm_api3('OptionGroup', 'get', ['name' => $group_name]);
-/**
- * looks up an option value
- *
- * the implementation is probably not optimal, but it'll do for the moment
- *
- * @return string|0
- */
-function banking_helper_optionvalue_by_name($group_id, $value_name): string|int {
- $result = civicrm_api3('OptionValue', 'get', [
- 'name' => $value_name,
- 'option_group_id' => $group_id,
- ]);
-
- if (empty($result['id'])) {
- Civi::log()->debug("org.project60.banking: Couldn't find option value '{$value_name}'!");
- return 0;
- }
- else {
- return $result['values'][$result['id']]['value'];
+ if (empty($result['id'])) {
+ Civi::log()->debug("org.project60.banking: Couldn't find option group '{$group_name}'!");
+ return 0;
+ }
+ else {
+ return (int) $result['id'];
+ }
}
-}
-/**
- * looks up an option value ID by group name and value name
- *
- * the implementation is probably not optimal, but it'll do for the moment
- *
- */
-function banking_helper_optionvalueid_by_groupname_and_name($group_name, $value_name): int {
- $group_id = banking_helper_optiongroupid_by_name($group_name);
- if ($group_id) {
- return banking_helper_optionvalueid_by_name($group_id, $value_name);
- }
- else {
- return 0;
+ /**
+ * looks up an option value
+ *
+ * the implementation is probably not optimal, but it'll do for the moment
+ *
+ */
+ public static function banking_helper_optionvalueid_by_name($group_id, $value_name): int {
+ $result = civicrm_api3('OptionValue', 'get', [
+ 'name' => $value_name,
+ 'option_group_id' => $group_id,
+ ]);
+
+ if (empty($result['id'])) {
+ Civi::log()->debug("org.project60.banking: Couldn't find option value '{$value_name}'!");
+ return 0;
+ }
+ else {
+ return (int) $result['id'];
+ }
}
-}
-/**
- * looks up an option value by group name and value name
- *
- * the implementation is probably not optimal, but it'll do for the moment
- *
- * @return string|0
- */
-function banking_helper_optionvalue_by_groupname_and_name($group_name, $value_name): string|int {
- $group_id = banking_helper_optiongroupid_by_name($group_name);
- if ($group_id) {
- return banking_helper_optionvalue_by_name($group_id, $value_name);
+ /**
+ * looks up an option value
+ *
+ * the implementation is probably not optimal, but it'll do for the moment
+ *
+ * @return string|0
+ */
+ public static function banking_helper_optionvalue_by_name($group_id, $value_name): string|int {
+ $result = civicrm_api3('OptionValue', 'get', [
+ 'name' => $value_name,
+ 'option_group_id' => $group_id,
+ ]);
+
+ if (empty($result['id'])) {
+ Civi::log()->debug("org.project60.banking: Couldn't find option value '{$value_name}'!");
+ return 0;
+ }
+ else {
+ return $result['values'][$result['id']]['value'];
+ }
}
- else {
- return 0;
+
+ /**
+ * looks up an option value ID by group name and value name
+ *
+ * the implementation is probably not optimal, but it'll do for the moment
+ *
+ */
+ public static function banking_helper_optionvalueid_by_groupname_and_name($group_name, $value_name): int {
+ $group_id = self::banking_helper_optiongroupid_by_name($group_name);
+ if ($group_id) {
+ return self::banking_helper_optionvalueid_by_name($group_id, $value_name);
+ }
+ else {
+ return 0;
+ }
}
-}
-/**
- * creates an id/name => object mapping for the given option group
- *
- * the implementation is probably not optimal, but it'll do for the moment
- *
- * @package org.project60.banking
- * @copyright GNU Affero General Public License
- * $Id$
- *
- */
-function banking_helper_optiongroup_id_name_mapping($group_name) {
- $group_id = banking_helper_optiongroupid_by_name($group_name);
-
- if ($group_id) {
- $result = civicrm_api3('OptionValue', 'get', ['option_group_id' => $group_id]);
- $mapping = [];
- foreach ($result['values'] as $entry) {
- $mapping[$entry['id']] = $entry;
- $mapping[$entry['name']] = $entry;
+ /**
+ * looks up an option value by group name and value name
+ *
+ * the implementation is probably not optimal, but it'll do for the moment
+ *
+ * @return string|0
+ */
+ public static function banking_helper_optionvalue_by_groupname_and_name($group_name, $value_name): string|int {
+ $group_id = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroupid_by_name($group_name);
+ if ($group_id) {
+ return CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_name($group_id, $value_name);
+ }
+ else {
+ return 0;
}
+ }
+
+ /**
+ * creates an id/name => object mapping for the given option group
+ *
+ * the implementation is probably not optimal, but it'll do for the moment
+ *
+ * @package org.project60.banking
+ * @copyright GNU Affero General Public License
+ * $Id$
+ *
+ */
+ public static function banking_helper_optiongroup_id_name_mapping($group_name) {
+ $group_id = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroupid_by_name($group_name);
- // inject 'new' value as id 0 for convenience
- $mapping[0] = $mapping['new'];
+ if ($group_id) {
+ $result = civicrm_api3('OptionValue', 'get', ['option_group_id' => $group_id]);
+ $mapping = [];
+ foreach ($result['values'] as $entry) {
+ $mapping[$entry['id']] = $entry;
+ $mapping[$entry['name']] = $entry;
+ }
- return $mapping;
+ // inject 'new' value as id 0 for convenience
+ $mapping[0] = $mapping['new'];
+ return $mapping;
+
+ }
+ else {
+ return [];
+ }
}
- else {
- return [];
+
+ /**
+ * will check if the given tx_status_id is closed,
+ * i.e. marked as 'processed' or 'ignored'
+ *
+ * @return TRUE if closed, FALSE otherwise
+ */
+ public static function banking_helper_tx_status_closed($tx_status_id) {
+ $status = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
+ return $status[$tx_status_id]['name'] == 'processed'
+ || $status[$tx_status_id]['name'] == 'ignored';
}
-}
-/**
- * will check if the given tx_status_id is closed,
- * i.e. marked as 'processed' or 'ignored'
- *
- * @return TRUE if closed, FALSE otherwise
- */
-function banking_helper_tx_status_closed($tx_status_id) {
- $status = banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
- return $status[$tx_status_id]['name'] == 'processed'
- || $status[$tx_status_id]['name'] == 'ignored';
}
diff --git a/CRM/Banking/Helpers/URLBuilder.php b/CRM/Banking/Helpers/URLBuilder.php
index b2eec7e4..181480c5 100755
--- a/CRM/Banking/Helpers/URLBuilder.php
+++ b/CRM/Banking/Helpers/URLBuilder.php
@@ -1,7 +1,4 @@
$value) {
- $params[$key] = $value;
- }
+ $params = [];
+ // take over selected parameters from source
+ foreach ($keep_params as $key) {
+ if (isset($keep_param_source[$key])) {
+ $params[$key] = $keep_param_source[$key];
+ }
+ }
- // remove requested parameters
- foreach ($delete_params as $key) {
- unset($params[$key]);
- }
+ // add (and override) the parameters
+ foreach ($set_params as $key => $value) {
+ $params[$key] = $value;
+ }
- // build string:
- $pstring = '';
- foreach ($params as $key => $value) {
- if (strlen($pstring) > 0) {
- $pstring = $pstring . '&';
+ // remove requested parameters
+ foreach ($delete_params as $key) {
+ unset($params[$key]);
}
- $pstring = $pstring . $key . '=' . $value;
+
+ // build string:
+ $pstring = '';
+ foreach ($params as $key => $value) {
+ if (strlen($pstring) > 0) {
+ $pstring = $pstring . '&';
+ }
+ $pstring = $pstring . $key . '=' . $value;
+ }
+
+ return CRM_Utils_System::url($base, $pstring, FALSE, NULL, FALSE);
}
- return CRM_Utils_System::url($base, $pstring, FALSE, NULL, FALSE);
}
diff --git a/CRM/Banking/Matcher/Engine.php b/CRM/Banking/Matcher/Engine.php
index 5c2878dd..089ce960 100755
--- a/CRM/Banking/Matcher/Engine.php
+++ b/CRM/Banking/Matcher/Engine.php
@@ -70,7 +70,7 @@ public static function clearCachedInstance() {
private function getMatchers() {
if ($this->matchers === NULL) {
$this->matchers = [];
- $matcher_type_id = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.plugin_classes', 'match');
+ $matcher_type_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.plugin_classes', 'match');
$params = ['plugin_type_id' => $matcher_type_id, 'enabled' => 1];
$result = civicrm_api3('BankingPluginInstance', 'get', $params);
if (isset($result['is_error']) && $result['is_error']) {
@@ -104,7 +104,7 @@ private function getPostprocessors() {
if ($this->postprocessors == NULL) {
$this->postprocessors = [];
- $postprocessor_type_id = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.plugin_classes', 'postprocess');
+ $postprocessor_type_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.plugin_classes', 'postprocess');
$params = ['plugin_type_id' => $postprocessor_type_id, 'enabled' => 1];
$result = civicrm_api3('BankingPluginInstance', 'get', $params);
if (isset($result['is_error']) && $result['is_error']) {
@@ -154,8 +154,8 @@ public function match($btx_id, $override_processed = FALSE) {
if (!$override_processed) {
// don't match already executed transactions...
- $processed_status_id = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
- $ignored_status_id = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Ignored');
+ $processed_status_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $ignored_status_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Ignored');
if ($btx->status_id == $processed_status_id || $btx->status_id == $ignored_status_id) {
// will not match already executed transactions
$lock->release();
@@ -221,7 +221,7 @@ public function match($btx_id, $override_processed = FALSE) {
$btx->saveSuggestions();
// set the status
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Suggestions');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Suggestions');
$btx->status_id = $newStatus;
$btx->setStatus($newStatus);
diff --git a/CRM/Banking/Matcher/Suggestion.php b/CRM/Banking/Matcher/Suggestion.php
index b1174d3e..d4e815ca 100755
--- a/CRM/Banking/Matcher/Suggestion.php
+++ b/CRM/Banking/Matcher/Suggestion.php
@@ -260,7 +260,7 @@ public function update_parameters($parameters) {
}
// only update if transaction still open (see BANKING-232)
- if (!banking_helper_tx_status_closed($this->_btx->status_id)) {
+ if (!CRM_Banking_Helpers_OptionValue::banking_helper_tx_status_closed($this->_btx->status_id)) {
$this->_plugin->update_parameters($this, $parameters);
$this->_btx->saveSuggestions();
return TRUE;
@@ -278,7 +278,7 @@ public function update_parameters($parameters) {
*/
public function execute($btx) {
// only execute if not completed yet
- if (!banking_helper_tx_status_closed($btx->status_id)) {
+ if (!CRM_Banking_Helpers_OptionValue::banking_helper_tx_status_closed($btx->status_id)) {
// perform execute
$result = $this->_plugin->execute($this, $btx);
if ($result && ($result !== 're-run')) {
diff --git a/CRM/Banking/Page/AccountDedupe.php b/CRM/Banking/Page/AccountDedupe.php
index 9a152303..8b1410bd 100644
--- a/CRM/Banking/Page/AccountDedupe.php
+++ b/CRM/Banking/Page/AccountDedupe.php
@@ -55,7 +55,7 @@ public function run() {
*/
public function findReferences() {
// look up reference types
- $reference_type_group_id = banking_helper_optiongroupid_by_name('civicrm_banking.reference_types');
+ $reference_type_group_id = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroupid_by_name('civicrm_banking.reference_types');
$reference_types = civicrm_api3('OptionValue', 'get', ['option_group_id' => $reference_type_group_id]);
$reference_types = $reference_types['values'];
diff --git a/CRM/Banking/Page/Dashboard.php b/CRM/Banking/Page/Dashboard.php
index 12665e81..54a3eb0d 100644
--- a/CRM/Banking/Page/Dashboard.php
+++ b/CRM/Banking/Page/Dashboard.php
@@ -30,7 +30,7 @@ public function run() {
$now = strtotime('now');
$week_count = 7;
$oldest_week = date('YW', strtotime("now -$week_count weeks"));
- $payment_states = banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
+ $payment_states = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
$account_names = [];
// get the week based data
diff --git a/CRM/Banking/Page/Payments.php b/CRM/Banking/Page/Payments.php
index 80b2be05..e5b411e7 100755
--- a/CRM/Banking/Page/Payments.php
+++ b/CRM/Banking/Page/Payments.php
@@ -25,7 +25,7 @@ public function run() {
CRM_Utils_System::setTitle(E::ts('Bank Transactions'));
// look up the payment states
- $payment_states = banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
+ $payment_states = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
if (!isset($_REQUEST['status_ids'])) {
$_REQUEST['status_ids'] = $payment_states['new']['id'];
@@ -50,15 +50,15 @@ public function run() {
// phpcs:enable
$this->assign('base_url', $base_url);
- $this->assign('url_show_payments', banking_helper_buildURL('civicrm/banking/payments', ['show' => 'payments', $list_type => '__selected__'], ['status_ids', 'recent']));
- $this->assign('url_show_statements', banking_helper_buildURL('civicrm/banking/payments', ['show' => 'statements'], ['status_ids', 'recent']));
+ $this->assign('url_show_payments', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', ['show' => 'payments', $list_type => '__selected__'], ['status_ids', 'recent']));
+ $this->assign('url_show_statements', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', ['show' => 'statements'], ['status_ids', 'recent']));
- $this->assign('url_show_payments_new', banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['status_ids' => $payment_states['new']['id']])));
- $this->assign('url_show_payments_analysed', banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['status_ids' => $payment_states['suggestions']['id']])));
- $this->assign('url_show_payments_completed', banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['status_ids' => $payment_states['processed']['id'] . ',' . $payment_states['ignored']['id']])));
+ $this->assign('url_show_payments_new', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['status_ids' => $payment_states['new']['id']])));
+ $this->assign('url_show_payments_analysed', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['status_ids' => $payment_states['suggestions']['id']])));
+ $this->assign('url_show_payments_completed', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['status_ids' => $payment_states['processed']['id'] . ',' . $payment_states['ignored']['id']])));
- $this->assign('url_review_selected_payments', banking_helper_buildURL('civicrm/banking/review', [$list_type => '__selected__']));
- $this->assign('url_export_selected_payments', banking_helper_buildURL('civicrm/banking/export', [$list_type => '__selected__']));
+ $this->assign('url_review_selected_payments', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', [$list_type => '__selected__']));
+ $this->assign('url_export_selected_payments', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/export', [$list_type => '__selected__']));
$this->assign('can_delete', CRM_Core_Permission::check('administer CiviCRM'));
@@ -102,7 +102,7 @@ public function build_statementPage($payment_states) {
// evaluate statement
$recently_closed_cutoff = CRM_Banking_Config::getRecentlyCompletedStatementCutoff();
if ($recently_closed_cutoff) {
- $this->assign('url_show_payments_recently_completed', banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['recent' => 1, 'status_ids' => $payment_states['processed']['id'] . ',' . $payment_states['ignored']['id']])));
+ $this->assign('url_show_payments_recently_completed', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters(['recent' => 1, 'status_ids' => $payment_states['processed']['id'] . ',' . $payment_states['ignored']['id']])));
}
// FIRST: CALCULATE COUNTS
diff --git a/CRM/Banking/Page/Review.php b/CRM/Banking/Page/Review.php
index 3ba465a4..3171ce89 100755
--- a/CRM/Banking/Page/Review.php
+++ b/CRM/Banking/Page/Review.php
@@ -69,7 +69,7 @@ public function run() {
$btx_bao->get('id', $pid);
// read the list of BTX statuses
- $choices = banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
+ $choices = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
// If the execution was triggered, run that first
if (isset($_REQUEST['execute'])) {
@@ -82,21 +82,21 @@ public function run() {
if ($new_ui_enabled) {
// Determine whether we should go back to the statements or statement lines
if (isset($_REQUEST['list'])) {
- $url_redirect = banking_helper_buildURL('civicrm/banking/statements/lines', ['s_id' => $btx_bao->tx_batch_id]);
+ $url_redirect = CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/statements/lines', ['s_id' => $btx_bao->tx_batch_id]);
}
elseif (isset($_REQUEST['s_list'])) {
- $url_redirect = banking_helper_buildURL('civicrm/banking/statements', []);
+ $url_redirect = CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/statements', []);
}
}
else {
- $url_redirect = banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters());
+ $url_redirect = CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters());
}
}
}
else {
// execution failed -> go back
if (isset($prev_pid)) {
- $url_redirect = banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $prev_pid]));
+ $url_redirect = CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $prev_pid]));
}
}
}
@@ -273,37 +273,37 @@ public function run() {
// URLs & stats
$unprocessed_count = 0;
$this->assign('new_ui_enabled', $new_ui_enabled);
- $this->assign('url_back', banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters()));
+ $this->assign('url_back', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', $this->_pageParameters()));
if ($new_ui_enabled) {
// Determine whether we should go back to the statements or statement lines
if (isset($_REQUEST['list'])) {
- $this->assign('url_back', banking_helper_buildURL('civicrm/banking/statements/lines', ['s_id' => $btx_bao->tx_batch_id]));
+ $this->assign('url_back', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/statements/lines', ['s_id' => $btx_bao->tx_batch_id]));
$this->assign('back_to_statement_lines', TRUE);
}
elseif (isset($_REQUEST['s_list'])) {
- $this->assign('url_back', banking_helper_buildURL('civicrm/banking/statements', []));
+ $this->assign('url_back', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/statements', []));
$this->assign('back_to_statement_lines', FALSE);
}
}
if (isset($next_pid)) {
- $this->assign('url_skip_forward', banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $next_pid])));
- $this->assign('url_execute', banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $next_pid, 'execute' => $pid])));
+ $this->assign('url_skip_forward', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $next_pid])));
+ $this->assign('url_execute', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $next_pid, 'execute' => $pid])));
$unprocessed_info = $this->getUnprocessedInfo($list, $next_pid, $choices);
if ($unprocessed_info) {
- $this->assign('url_skip_processed', banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $unprocessed_info['next_unprocessed_pid']])));
+ $this->assign('url_skip_processed', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $unprocessed_info['next_unprocessed_pid']])));
$unprocessed_count = $unprocessed_info['unprocessed_count'];
}
}
else {
- $this->assign('url_execute', banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['execute' => $pid])));
+ $this->assign('url_execute', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['execute' => $pid])));
}
if (isset($prev_pid)) {
- $this->assign('url_skip_back', banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $prev_pid])));
+ $this->assign('url_skip_back', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/review', $this->_pageParameters(['id' => $prev_pid])));
}
- $this->assign('url_show_payments', banking_helper_buildURL('civicrm/banking/payments', ['show' => 'payments']));
+ $this->assign('url_show_payments', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/payments', ['show' => 'payments']));
// phpcs:disable Squiz.PHP.GlobalKeyword.NotAllowed
global $base_url;
diff --git a/CRM/Banking/Page/Statements.php b/CRM/Banking/Page/Statements.php
index 0154fb38..11cdb25e 100644
--- a/CRM/Banking/Page/Statements.php
+++ b/CRM/Banking/Page/Statements.php
@@ -18,7 +18,7 @@ public function run() {
$config = CRM_Core_Config::singleton();
CRM_Utils_System::setTitle(E::ts('Banking statements'));
$this->assign('can_delete', CRM_Core_Permission::check('administer CiviCRM'));
- $this->assign('url_export_selected_payments', banking_helper_buildURL('civicrm/banking/export', ['s_list' => '__selected__']));
+ $this->assign('url_export_selected_payments', CRM_Banking_Helpers_URLBuilder::banking_helper_buildURL('civicrm/banking/export', ['s_list' => '__selected__']));
$statements = [];
// collect an array of target accounts, serving to limit the display
diff --git a/CRM/Banking/PluginImpl/Matcher/AccountLookup.php b/CRM/Banking/PluginImpl/Matcher/AccountLookup.php
index a5aea6a8..a28ef887 100644
--- a/CRM/Banking/PluginImpl/Matcher/AccountLookup.php
+++ b/CRM/Banking/PluginImpl/Matcher/AccountLookup.php
@@ -163,7 +163,7 @@ protected function lookupBankAccount($type_id, string $reference, CRM_Banking_Ma
protected function getReferenceTypes($context) {
$types = $context->getCachedEntry('analyser_account.reference_types');
if ($types === NULL) {
- $group_id = banking_helper_optiongroupid_by_name('civicrm_banking.reference_types');
+ $group_id = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroupid_by_name('civicrm_banking.reference_types');
$types = CRM_Core_OptionGroup::valuesByID($group_id, $flip = TRUE, $grouping = FALSE, $localize = FALSE, $labelColumnName = 'id', $onlyActive = TRUE, $fresh = FALSE);
$context->setCachedEntry('analyser_account.reference_types', $types);
}
diff --git a/CRM/Banking/PluginImpl/Matcher/Batches.php b/CRM/Banking/PluginImpl/Matcher/Batches.php
index f99713cb..f534eb07 100644
--- a/CRM/Banking/PluginImpl/Matcher/Batches.php
+++ b/CRM/Banking/PluginImpl/Matcher/Batches.php
@@ -139,7 +139,7 @@ public function execute($suggestion, $btx) {
if ($suggestion->getParameter('override_status') || !count($this->getNonPendingContributionIDs($batch_id))) {
// all seems fine, lets set all these contributions to 'completed'
- $contribution_status_completed = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
+ $contribution_status_completed = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
// first, get all contributions:
$contributionIDs = [];
@@ -162,7 +162,7 @@ public function execute($suggestion, $btx) {
}
// update the batch
- $batch_status_received = banking_helper_optionvalue_by_groupname_and_name('batch_status', 'Received');
+ $batch_status_received = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('batch_status', 'Received');
$update_batch_query = ['id' => $batch_id, 'modified_date' => date('YmdHis'), 'status_id' => $batch_status_received];
$result = civicrm_api3('Batch', 'create', $update_batch_query);
if ($result['is_error']) {
@@ -173,7 +173,7 @@ public function execute($suggestion, $btx) {
CRM_Core_Session::setStatus(sprintf(E::ts('Completed all %d contributions.'), count($contributionIDs)), E::ts('Batch completed'), 'info');
// complete by setting the status to 'processed'
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
@@ -299,7 +299,7 @@ public function generateBatchList() {
*/
public function getNonPendingContributionIDs($batch_id) {
$nonPendingContributionIDs = [];
- $contribution_status_pending = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Pending');
+ $contribution_status_pending = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Pending');
$query =
'SELECT contribution.id as contribution_id FROM civicrm_entity_batch AS batch ' .
"INNER JOIN civicrm_entity_financial_trxn AS trxn2c ON batch.entity_id=trxn2c.financial_trxn_id AND batch.entity_table='civicrm_financial_trxn' " .
diff --git a/CRM/Banking/PluginImpl/Matcher/CreateCampaignContribution.php b/CRM/Banking/PluginImpl/Matcher/CreateCampaignContribution.php
index 82f55824..dc88f246 100644
--- a/CRM/Banking/PluginImpl/Matcher/CreateCampaignContribution.php
+++ b/CRM/Banking/PluginImpl/Matcher/CreateCampaignContribution.php
@@ -312,7 +312,7 @@ public function execute($suggestion, $btx) {
}
// wrap it up
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/CreateContribution.php b/CRM/Banking/PluginImpl/Matcher/CreateContribution.php
index 1be3fbd7..d2123411 100644
--- a/CRM/Banking/PluginImpl/Matcher/CreateContribution.php
+++ b/CRM/Banking/PluginImpl/Matcher/CreateContribution.php
@@ -117,7 +117,7 @@ public function execute($suggestion, $btx) {
CRM_Banking_BAO_BankTransactionContribution::linkContribution($btx->id, $result['id']);
// wrap it up
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/CreateMultipleContributions.php b/CRM/Banking/PluginImpl/Matcher/CreateMultipleContributions.php
index 7cad0f2a..a69f6e14 100644
--- a/CRM/Banking/PluginImpl/Matcher/CreateMultipleContributions.php
+++ b/CRM/Banking/PluginImpl/Matcher/CreateMultipleContributions.php
@@ -375,7 +375,7 @@ public function execute($suggestion, $btx) {
);
// Wrap it up.
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name(
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name(
'civicrm_banking.bank_tx_status',
'Processed'
);
diff --git a/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php b/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php
index eca6e505..84e6e205 100644
--- a/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php
+++ b/CRM/Banking/PluginImpl/Matcher/DefaultOptions.php
@@ -180,8 +180,8 @@ public function execute($suggestion, $btx) {
$cids = $suggestion->getParameter('contribution_ids');
$contribution_count = 0;
if ($cids) {
- $completed_status = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
- $cancelled_status = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
+ $completed_status = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
+ $cancelled_status = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
foreach ($cids as $cid) {
if ($cid) {
@@ -231,7 +231,7 @@ public function execute($suggestion, $btx) {
}
if ($contribution_count > 0) {
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
}
@@ -248,7 +248,7 @@ public function execute($suggestion, $btx) {
}
else {
// this is the IGNORE action. Simply set the status to ignored
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Ignored');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Ignored');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
}
@@ -292,7 +292,7 @@ public function visualize_match(CRM_Banking_Matcher_Suggestion $match, $btx) {
$smarty_vars['injected_contribution_ids'] = $match->getParameter('injected_contribution_ids');
$smarty_vars['ignore_message'] = $this->_plugin_config->ignore_message;
$smarty_vars['booking_date'] = date('YmdHis', strtotime($btx->booking_date));
- $smarty_vars['status_pending'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Pending');
+ $smarty_vars['status_pending'] = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Pending');
$smarty_vars['manual_default_source'] = $this->_plugin_config->manual_default_source;
$smarty_vars['manual_default_financial_type_id'] = $this->_plugin_config->manual_default_financial_type_id;
$smarty_vars['create_propagation'] = $this->getPropagationSet($btx, $match, 'contribution', $this->_plugin_config->createnew_value_propagation);
diff --git a/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php b/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
index 728599d1..61d6b5ef 100644
--- a/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
+++ b/CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
@@ -19,7 +19,7 @@
use CRM_Banking_ExtensionUtil as E;
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
-require_once 'packages/eval-math/evalmath.class.php';
+require_once E::path('packages/eval-math/evalmath.class.php');
// phpcs:enable
/**
@@ -244,7 +244,7 @@ public function rateContribution($contribution, $context): int|float {
if ($config->payment_instrument_penalty
&& isset($contribution['payment_instrument_id'])
&& isset($parsed_data['payment_instrument'])) {
- $contribution_payment_instrument_id = banking_helper_optionvalue_by_groupname_and_name('payment_instrument', $parsed_data['payment_instrument']);
+ $contribution_payment_instrument_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('payment_instrument', $parsed_data['payment_instrument']);
if ($contribution_payment_instrument_id != $contribution['payment_instrument_id']) {
$payment_instrument_penalty = $config->payment_instrument_penalty;
}
@@ -322,7 +322,7 @@ public function getPotentialContributionsForContact($contact_id, CRM_Banking_Mat
protected function getAcceptedContributionStatusIDs(): array {
$accepted_status_ids = [];
foreach ($this->_plugin_config->accepted_contribution_states as $status_name) {
- $status_id = banking_helper_optionvalue_by_groupname_and_name('contribution_status', $status_name);
+ $status_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', $status_name);
if ($status_id) {
// @todo Are these integerish strings? Should they be cast to int?
$accepted_status_ids[] = $status_id;
@@ -551,13 +551,13 @@ public function execute($suggestion, $btx) {
// depending on mode...
if ($this->_plugin_config->mode != 'cancellation') {
- $query['contribution_status_id'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
+ $query['contribution_status_id'] = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
if (!$config->preserve_receive_date) {
$query['receive_date'] = date('YmdHis', strtotime($btx->booking_date));
}
}
else {
- $query['contribution_status_id'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
+ $query['contribution_status_id'] = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
$query['cancel_date'] = date('YmdHis', strtotime($btx->booking_date));
if ($config->cancellation_cancel_reason) {
$query['cancel_reason'] = $suggestion->getParameter('cancel_reason');
@@ -584,7 +584,7 @@ public function execute($suggestion, $btx) {
}
}
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/Ignore.php b/CRM/Banking/PluginImpl/Matcher/Ignore.php
index be6c59f6..f4dd0976 100644
--- a/CRM/Banking/PluginImpl/Matcher/Ignore.php
+++ b/CRM/Banking/PluginImpl/Matcher/Ignore.php
@@ -98,7 +98,7 @@ public function match(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matcher_
*/
public function execute($suggestion, $btx) {
// this is the IGNORE action. Simply set the status to ignored
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Ignored');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Ignored');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/Membership.php b/CRM/Banking/PluginImpl/Matcher/Membership.php
index af863ecd..43ec0599 100644
--- a/CRM/Banking/PluginImpl/Matcher/Membership.php
+++ b/CRM/Banking/PluginImpl/Matcher/Membership.php
@@ -129,7 +129,7 @@ public function execute($suggestion, $btx) {
$this->storeAccountWithContact($btx, $membership['contact_id']);
CRM_Banking_BAO_BankTransactionContribution::linkContribution($btx->id, $contribution['id']);
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/RecurringContribution.php b/CRM/Banking/PluginImpl/Matcher/RecurringContribution.php
index 676e7a48..187e7501 100644
--- a/CRM/Banking/PluginImpl/Matcher/RecurringContribution.php
+++ b/CRM/Banking/PluginImpl/Matcher/RecurringContribution.php
@@ -271,7 +271,7 @@ public function execute($suggestion, $btx) {
$contribution['payment_instrument_id'] = $rcontribution['payment_instrument_id'] ?? NULL;
$contribution['campaign_id'] = $rcontribution['campaign_id'] ?? NULL;
$contribution['contribution_recur_id'] = $rcontribution_id;
- $contribution['contribution_status_id'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', $config->created_contribution_status);
+ $contribution['contribution_status_id'] = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', $config->created_contribution_status);
$contribution = array_merge($contribution, $this->getPropagationSet($btx, $suggestion, 'contribution'));
$result = civicrm_api3('Contribution', 'create', $contribution);
if (isset($result['is_error']) && $result['is_error']) {
@@ -292,7 +292,7 @@ public function execute($suggestion, $btx) {
$contribution['payment_instrument_id'] = $rcontribution['payment_instrument_id'] ?? NULL;
$contribution['campaign_id'] = $rcontribution['campaign_id'] ?? NULL;
$contribution['contribution_recur_id'] = $rcontribution['id'];
- $contribution['contribution_status_id'] = banking_helper_optionvalue_by_groupname_and_name('contribution_status', $config->created_contribution_status);
+ $contribution['contribution_status_id'] = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', $config->created_contribution_status);
$contribution = array_merge($contribution, $this->getPropagationSet($btx, $suggestion, 'contribution'));
$result = civicrm_api3('Contribution', 'create', $contribution);
if (isset($result['is_error']) && $result['is_error']) {
@@ -315,7 +315,7 @@ public function execute($suggestion, $btx) {
// save the account
$this->storeAccountWithContact($btx, $suggestion->getParameter('contact_id'));
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($suggestion, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/Rules.php b/CRM/Banking/PluginImpl/Matcher/Rules.php
index 59083fb8..91a2ba4a 100644
--- a/CRM/Banking/PluginImpl/Matcher/Rules.php
+++ b/CRM/Banking/PluginImpl/Matcher/Rules.php
@@ -101,7 +101,7 @@ public function execute($match, $btx) {
$rule_match->execute($match);
// update status
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($match, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginImpl/Matcher/RulesAnalyser.php b/CRM/Banking/PluginImpl/Matcher/RulesAnalyser.php
index 00b67aa0..13d0136f 100644
--- a/CRM/Banking/PluginImpl/Matcher/RulesAnalyser.php
+++ b/CRM/Banking/PluginImpl/Matcher/RulesAnalyser.php
@@ -19,10 +19,6 @@
use CRM_Banking_ExtensionUtil as E;
-// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
-require_once 'CRM/Banking/Helpers/OptionValue.php';
-// phpcs:enable
-
define('BANKING_MATCHER_RULE_TYPE_ANALYSER', 1);
define('BANKING_MATCHER_RULE_TYPE_MATCHER', 2);
diff --git a/CRM/Banking/PluginImpl/Matcher/SepaMandate.php b/CRM/Banking/PluginImpl/Matcher/SepaMandate.php
index ea2059c9..59abd5f9 100644
--- a/CRM/Banking/PluginImpl/Matcher/SepaMandate.php
+++ b/CRM/Banking/PluginImpl/Matcher/SepaMandate.php
@@ -19,7 +19,7 @@
use CRM_Banking_ExtensionUtil as E;
// phpcs:disable PSR1.Files.SideEffects.FoundWithSymbols
-require_once 'packages/eval-math/evalmath.class.php';
+require_once E::path('packages/eval-math/evalmath.class.php');
// phpcs:enable
/**
@@ -314,7 +314,7 @@ public function match(CRM_Banking_BAO_BankTransaction $btx, CRM_Banking_Matcher_
$suggestion->addEvidence($config->deviation_penalty, E::ts('The contribution does not feature the expected amount.'));
$probability -= $config->deviation_penalty;
}
- $status_inprogress = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'In Progress');
+ $status_inprogress = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'In Progress');
if ($contribution['contribution_status_id'] != $status_inprogress) {
$suggestion->addEvidence($config->deviation_penalty, E::ts("The contribution does not have the expected status 'in Progress'."));
$probability -= $config->deviation_penalty;
@@ -430,9 +430,9 @@ public function execute($match, $btx) {
}
$contribution_id = $match->getParameter('contribution_id');
- $status_pending = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Pending');
- $status_inprogress = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'In Progress');
- $status_completed = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
+ $status_pending = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Pending');
+ $status_inprogress = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'In Progress');
+ $status_completed = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Completed');
// Compatibility with CiviCRM < 4.7.0
if (version_compare(CRM_Utils_System::version(), '4.7.0', '<')) {
@@ -502,7 +502,7 @@ public function execute($match, $btx) {
$result = CRM_Core_DAO::executeQuery($open_contributions_in_group_sql);
if ($result->fetch() && $result->open_count == 0) {
// set this group's status to 'received'
- $group_status_id_received = banking_helper_optionvalue_by_groupname_and_name('batch_status', 'Received');
+ $group_status_id_received = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('batch_status', 'Received');
if ($group_status_id_received) {
$txgroup_query = ['id' => $txgroup_id, 'status_id' => $group_status_id_received];
$close_result = civicrm_api3('SepaTransactionGroup', 'create', $txgroup_query);
@@ -520,7 +520,7 @@ public function execute($match, $btx) {
}
}
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($match, $btx);
return TRUE;
@@ -561,7 +561,7 @@ public function executeCancellation($match, $btx) {
$status_cancelled = $config->cancelled_contribution_status_id;
}
else {
- $status_cancelled = banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
+ $status_cancelled = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalue_by_groupname_and_name('contribution_status', 'Cancelled');
}
$this->logger->setTimer('sepa_mandate_cancel_contribution');
@@ -765,7 +765,7 @@ public function executeCancellation($match, $btx) {
// link contribution
CRM_Banking_BAO_BankTransactionContribution::linkContribution($btx->id, $contribution_id);
- $newStatus = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
+ $newStatus = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', 'Processed');
$btx->setStatus($newStatus);
parent::execute($match, $btx);
return TRUE;
diff --git a/CRM/Banking/PluginModel/Importer.php b/CRM/Banking/PluginModel/Importer.php
index e9761e84..bea098c5 100755
--- a/CRM/Banking/PluginModel/Importer.php
+++ b/CRM/Banking/PluginModel/Importer.php
@@ -125,7 +125,7 @@ abstract public function import_stream($params);
*/
public function __construct($plugin_dao) {
parent::__construct($plugin_dao);
- $this->_default_btx_state_id = banking_helper_optionvalueid_by_groupname_and_name(
+ $this->_default_btx_state_id = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name(
'civicrm_banking.bank_tx_status',
'new'
);
diff --git a/api/v3/BankingTransaction.php b/api/v3/BankingTransaction.php
index 223cac20..615d38c2 100755
--- a/api/v3/BankingTransaction.php
+++ b/api/v3/BankingTransaction.php
@@ -142,7 +142,7 @@ function civicrm_api3_banking_transaction_analyselist($params) {
}
// filter for non-closed statements
- $payment_states = banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
+ $payment_states = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
$state_ignored = (int) $payment_states['ignored']['id'];
$state_processed = (int) $payment_states['processed']['id'];
$list_string = implode(',', $tx_ids);
diff --git a/banking.civix.php b/banking.civix.php
index ce5e2500..863b9d59 100755
--- a/banking.civix.php
+++ b/banking.civix.php
@@ -89,7 +89,6 @@ public static function schema() {
use CRM_Banking_ExtensionUtil as E;
-($GLOBALS['_PathLoad'][0] ?? require __DIR__ . '/mixin/lib/pathload-0.php');
pathload()->addSearchDir(__DIR__ . '/mixin/lib');
spl_autoload_register('_banking_civix_class_loader', TRUE, TRUE);
diff --git a/info.xml b/info.xml
index 6398b3b4..f4ac3ea2 100755
--- a/info.xml
+++ b/info.xml
@@ -30,14 +30,15 @@
Implements handling of bank accounts for contacts, as well as handling of bank files (and individual bank payments extracted from the files). Bank files can be imported, transactions matched to CiviCRM entities, and the resulting data exported. Specific handlers for all of these actions are provided through plugins, some of which are shipped with the core banking extension, while some more complex ones are provided in separate extensions. More information here: https://docs.civicrm.org/banking/en/latest
CRM/Banking
- 24.09.1
+ 25.10.2
ang-php@1.0.0
menu-xml@1.0.0
- mgd-php@1.0.0
- smarty-v2@1.0.3
+ mgd-php@2.0.0
entity-types-php@1.0.0
+ scan-classes@1.0.0
+ smarty@1.0.3
CRM_Banking_Upgrader
diff --git a/mixin/lib/civimix-schema@5.78.beta1.phar b/mixin/lib/civimix-schema@5.78.beta1.phar
deleted file mode 100644
index 079ec362..00000000
Binary files a/mixin/lib/civimix-schema@5.78.beta1.phar and /dev/null differ
diff --git a/mixin/lib/civimix-schema@5.93.0/pathload.main.php b/mixin/lib/civimix-schema@5.93.0/pathload.main.php
new file mode 100644
index 00000000..f0442e84
--- /dev/null
+++ b/mixin/lib/civimix-schema@5.93.0/pathload.main.php
@@ -0,0 +1,28 @@
+activatePackage('civimix-schema@5', __DIR__, [
+ 'reloadable' => TRUE,
+ // The civimix-schema library specifically supports installation processes. From a
+ // bootstrap/service-availability POV, this is a rough environment which leads to
+ // the "Multi-Activation Issue" and "Multi-Download Issue". To adapt to them,
+ // civimix-schema follows "Reloadable Library" patterns.
+ // More information: https://github.com/totten/pathload-poc/blob/master/doc/issues.md
+]);
+
+// When reloading, we make newer instance of the Facade object.
+$GLOBALS['CiviMixSchema'] = require __DIR__ . '/src/CiviMixSchema.php';
+
+if (!interface_exists(__NAMESPACE__ . '\SchemaHelperInterface')) {
+ require __DIR__ . '/src/SchemaHelperInterface.php';
+}
+
+// \CiviMix\Schema\loadClass() is a facade. The facade should remain identical across versions.
+if (!function_exists(__NAMESPACE__ . '\loadClass')) {
+
+ function loadClass(string $class) {
+ return $GLOBALS['CiviMixSchema']->loadClass($class);
+ }
+
+ spl_autoload_register(__NAMESPACE__ . '\loadClass');
+}
diff --git a/mixin/lib/civimix-schema@5.93.0/src/AutomaticUpgrader.php b/mixin/lib/civimix-schema@5.93.0/src/AutomaticUpgrader.php
new file mode 100644
index 00000000..db6140b7
--- /dev/null
+++ b/mixin/lib/civimix-schema@5.93.0/src/AutomaticUpgrader.php
@@ -0,0 +1,181 @@
+initIdentity($params);
+ if ($info = $this->getInfo()) {
+ if ($class = $this->getDelegateUpgraderClass($info)) {
+ $this->customUpgrader = new $class();
+ $this->customUpgrader->init($params);
+ if ($errors = $this->checkDelegateCompatibility($this->customUpgrader)) {
+ throw new \CRM_Core_Exception("AutomaticUpgrader is not compatible with $class:\n" . implode("\n", $errors));
+ }
+ }
+ }
+ }
+
+ public function notify(string $event, array $params = []) {
+ $info = $this->getInfo();
+ if (!$info) {
+ return;
+ }
+
+ if ($event === 'install') {
+ $GLOBALS['CiviMixSchema']->getHelper($this->getExtensionKey())->install();
+ }
+
+ if ($this->customUpgrader) {
+ $result = $this->customUpgrader->notify($event, $params);
+ // for upgrade checks, we need to pass check results up to the caller
+ // (for now - could definitely be more elegant!)
+ if ($event === 'upgrade') {
+ return $result;
+ }
+ }
+
+ if ($event === 'uninstall') {
+ $GLOBALS['CiviMixSchema']->getHelper($this->getExtensionKey())->uninstall();
+ }
+ }
+
+ /**
+ * Civix-based extensions have a conventional name for their upgrader class ("CRM_Myext_Upgrader"
+ * or "Civi\Myext\Upgrader"). Figure out if this class exists.
+ *
+ * @param \CRM_Extension_Info $info
+ * @return string|null
+ * Ex: 'CRM_Myext_Upgrader' or 'Civi\Myext\Upgrader'
+ */
+ public function getDelegateUpgraderClass(\CRM_Extension_Info $info): ?string {
+ $candidates = [];
+
+ if (!empty($info->civix['namespace'])) {
+ $namespace = $info->civix['namespace'];
+ $candidates[] = sprintf('%s_Upgrader', str_replace('/', '_', $namespace));
+ $candidates[] = sprintf('%s\\Upgrader', str_replace('/', '\\', $namespace));
+ }
+
+ foreach ($candidates as $candidate) {
+ if (class_exists($candidate)) {
+ return $candidate;
+ }
+ }
+
+ return NULL;
+ }
+
+ public function getInfo(): ?\CRM_Extension_Info {
+ try {
+ return \CRM_Extension_System::singleton()->getMapper()->keyToInfo($this->extensionName);
+ }
+ catch (\CRM_Extension_Exception_ParseException $e) {
+ \Civi::log()->error("Parse error in extension " . $this->extensionName . ": " . $e->getMessage());
+ return NULL;
+ }
+ }
+
+ /**
+ * @param \CRM_Extension_Upgrader_Interface $upgrader
+ * @return array
+ * List of error messages.
+ */
+ public function checkDelegateCompatibility($upgrader): array {
+ $class = get_class($upgrader);
+
+ $errors = [];
+
+ if (!($upgrader instanceof \CRM_Extension_Upgrader_Base)) {
+ $errors[] = "$class is not based on CRM_Extension_Upgrader_Base.";
+ return $errors;
+ }
+
+ // In the future, we will probably modify AutomaticUpgrader to build its own
+ // sequence of revisions (based on other sources of data). AutomaticUpgrader
+ // is only regarded as compatible with classes that strictly follow the standard revision-model.
+ $methodNames = [
+ 'appendTask',
+ 'onUpgrade',
+ 'getRevisions',
+ 'getCurrentRevision',
+ 'setCurrentRevision',
+ 'enqueuePendingRevisions',
+ 'hasPendingRevisions',
+ ];
+ foreach ($methodNames as $methodName) {
+ $method = new \ReflectionMethod($upgrader, $methodName);
+ if ($method->getDeclaringClass()->getName() !== 'CRM_Extension_Upgrader_Base') {
+ $errors[] = "To ensure future interoperability, AutomaticUpgrader only supports {$class}::{$methodName}() if it's inherited from CRM_Extension_Upgrader_Base";
+ }
+ }
+
+ return $errors;
+ }
+
+ public function __set($property, $value) {
+ switch ($property) {
+ // _queueAdapter() needs these properties.
+ case 'ctx':
+ case 'queue':
+ if (!$this->customUpgrader) {
+ throw new \RuntimeException("AutomaticUpgrader($this->extensionName): Cannot assign delegated property: $property (No custom-upgrader found)");
+ }
+ // "Invasive": unlike QueueTrait, we are not in the same class as the recipient. And we can't replace previously-published QueueTraits.
+ Invasive::set([$this->customUpgrader, $property], $value);
+ return;
+ }
+
+ throw new \RuntimeException("AutomaticUpgrader($this->extensionName): Cannot assign unknown property: $property");
+ }
+
+ public function __get($property) {
+ switch ($property) {
+ // _queueAdapter() needs these properties.
+ case 'ctx':
+ case 'queue':
+ if (!$this->customUpgrader) {
+ throw new \RuntimeException("AutomaticUpgrader($this->extensionName): Cannot read delegated property: $property (No custom-upgrader found)");
+ }
+ // "Invasive": Unlike QueueTrait, we are not in the same class as the recipient. And we can't replace previously-published QueueTraits.
+ return Invasive::get([$this->customUpgrader, $property]);
+ }
+ throw new \RuntimeException("AutomaticUpgrader($this->extensionName): Cannot read unknown property: $property");
+ }
+
+ public function __call($name, $arguments) {
+ if ($this->customUpgrader) {
+ return call_user_func_array([$this->customUpgrader, $name], $arguments);
+ }
+ else {
+ throw new \RuntimeException("AutomaticUpgrader($this->extensionName): Cannot delegate method $name (No custom-upgrader found)");
+ }
+ }
+
+};
diff --git a/mixin/lib/civimix-schema@5.93.0/src/CiviMixSchema.php b/mixin/lib/civimix-schema@5.93.0/src/CiviMixSchema.php
new file mode 100644
index 00000000..6d0a350a
--- /dev/null
+++ b/mixin/lib/civimix-schema@5.93.0/src/CiviMixSchema.php
@@ -0,0 +1,46 @@
+regex, $class, $m)) {
+ $absPath = __DIR__ . DIRECTORY_SEPARATOR . $m[2] . '.php';
+ class_alias(get_class(require $absPath), $class);
+ }
+ }
+
+ /**
+ * @param string $extensionKey
+ * Ex: 'org.civicrm.flexmailer'
+ * @return \CiviMix\Schema\SchemaHelperInterface
+ */
+ public function getHelper(string $extensionKey) {
+ $store = &\Civi::$statics['CiviMixSchema-helpers'];
+ if (!isset($store[$extensionKey])) {
+ $class = get_class(require __DIR__ . '/SchemaHelper.php');
+ $store[$extensionKey] = new $class($extensionKey);
+ }
+ return $store[$extensionKey];
+ }
+
+};
diff --git a/mixin/lib/civimix-schema@5.93.0/src/DAO.php b/mixin/lib/civimix-schema@5.93.0/src/DAO.php
new file mode 100644
index 00000000..3b82b27b
--- /dev/null
+++ b/mixin/lib/civimix-schema@5.93.0/src/DAO.php
@@ -0,0 +1,350 @@
+ $field) {
+ $this->$name = NULL;
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function keys(): array {
+ $keys = [];
+ foreach (static::getEntityDefinition()['getFields']() as $name => $field) {
+ if (!empty($field['primary_key'])) {
+ $keys[] = $name;
+ }
+ }
+ return $keys;
+ }
+
+ public static function getEntityTitle($plural = FALSE) {
+ $info = static::getEntityInfo();
+ return ($plural && isset($info['title_plural'])) ? $info['title_plural'] : $info['title'];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getEntityPaths(): array {
+ $definition = static::getEntityDefinition();
+ if (isset($definition['getPaths'])) {
+ return $definition['getPaths']();
+ }
+ return [];
+ }
+
+ public static function getLabelField(): ?string {
+ return static::getEntityInfo()['label_field'] ?? NULL;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getEntityDescription(): ?string {
+ return static::getEntityInfo()['description'] ?? NULL;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getTableName() {
+ return static::getEntityDefinition()['table'];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getLog(): bool {
+ return static::getEntityInfo()['log'] ?? FALSE;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getEntityIcon(string $entityName, ?int $entityId = NULL): ?string {
+ return static::getEntityInfo()['icon'] ?? NULL;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected static function getTableAddVersion(): string {
+ return static::getEntityInfo()['add'] ?? '1.0';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getExtensionName(): ?string {
+ return static::getEntityDefinition()['module'];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function &fields() {
+ $fields = [];
+ foreach (static::getSchemaFields() as $field) {
+ $key = $field['uniqueName'] ?? $field['name'];
+ unset($field['uniqueName']);
+ $fields[$key] = $field;
+ }
+ return $fields;
+ }
+
+ private static function getSchemaFields(): array {
+ if (!isset(\Civi::$statics[static::class]['fields'])) {
+ \Civi::$statics[static::class]['fields'] = static::loadSchemaFields();
+ }
+ return \Civi::$statics[static::class]['fields'];
+ }
+
+ private static function loadSchemaFields(): array {
+ $fields = [];
+ $entityDef = static::getEntityDefinition();
+ $baoName = \CRM_Core_DAO_AllCoreTables::getBAOClassName(static::class);
+
+ foreach ($entityDef['getFields']() as $fieldName => $fieldSpec) {
+ $field = [
+ 'name' => $fieldName,
+ 'type' => !empty($fieldSpec['data_type']) ? \CRM_Utils_Type::getValidTypes()[$fieldSpec['data_type']] : static::getCrmTypeFromSqlType($fieldSpec['sql_type']),
+ 'title' => $fieldSpec['title'],
+ 'description' => $fieldSpec['description'] ?? NULL,
+ ];
+ if (!empty($fieldSpec['required'])) {
+ $field['required'] = TRUE;
+ }
+ if (strpos($fieldSpec['sql_type'], 'decimal(') === 0) {
+ $precision = self::getFieldLength($fieldSpec['sql_type']);
+ $field['precision'] = array_map('intval', explode(',', $precision));
+ }
+ foreach (['maxlength', 'size', 'rows', 'cols'] as $attr) {
+ if (isset($fieldSpec['input_attrs'][$attr])) {
+ $field[$attr] = $fieldSpec['input_attrs'][$attr];
+ unset($fieldSpec['input_attrs'][$attr]);
+ }
+ }
+ if (strpos($fieldSpec['sql_type'], 'char(') !== FALSE) {
+ $length = self::getFieldLength($fieldSpec['sql_type']);
+ if (!isset($field['size'])) {
+ $field['size'] = constant(static::getDefaultSize($length));
+ }
+ if (!isset($field['maxlength'])) {
+ $field['maxlength'] = $length;
+ }
+ }
+ $usage = $fieldSpec['usage'] ?? [];
+ $field['usage'] = [
+ 'import' => in_array('import', $usage),
+ 'export' => in_array('export', $usage),
+ 'duplicate_matching' => in_array('duplicate_matching', $usage),
+ 'token' => in_array('token', $usage),
+ ];
+ if ($field['usage']['import']) {
+ $field['import'] = TRUE;
+ }
+ $field['where'] = $entityDef['table'] . '.' . $field['name'];
+ if ($field['usage']['export'] || (!$field['usage']['export'] && $field['usage']['import'])) {
+ $field['export'] = $field['usage']['export'];
+ }
+ if (!empty($fieldSpec['contact_type'])) {
+ $field['contactType'] = $fieldSpec['contact_type'];
+ }
+ if (!empty($fieldSpec['permission'])) {
+ $field['permission'] = $fieldSpec['permission'];
+ }
+ if (array_key_exists('default', $fieldSpec)) {
+ $field['default'] = isset($fieldSpec['default']) ? (string) $fieldSpec['default'] : NULL;
+ if (is_bool($fieldSpec['default'])) {
+ $field['default'] = $fieldSpec['default'] ? '1' : '0';
+ }
+ }
+ $field['table_name'] = $entityDef['table'];
+ $field['entity'] = $entityDef['name'];
+ $field['bao'] = $baoName;
+ $field['localizable'] = intval($fieldSpec['localizable'] ?? 0);
+ if (!empty($fieldSpec['localize_context'])) {
+ $field['localize_context'] = (string) $fieldSpec['localize_context'];
+ }
+ if (!empty($fieldSpec['entity_reference'])) {
+ if (!empty($fieldSpec['entity_reference']['entity'])) {
+ $field['FKClassName'] = static::getDAONameForEntity($fieldSpec['entity_reference']['entity']);
+ }
+ if (!empty($fieldSpec['entity_reference']['dynamic_entity'])) {
+ $field['DFKEntityColumn'] = $fieldSpec['entity_reference']['dynamic_entity'];
+ }
+ $field['FKColumnName'] = $fieldSpec['entity_reference']['key'] ?? 'id';
+ }
+ if (!empty($fieldSpec['component'])) {
+ $field['component'] = $fieldSpec['component'];
+ }
+ if (!empty($fieldSpec['serialize'])) {
+ $field['serialize'] = $fieldSpec['serialize'];
+ }
+ if (!empty($fieldSpec['unique_name'])) {
+ $field['uniqueName'] = $fieldSpec['unique_name'];
+ }
+ if (!empty($fieldSpec['unique_title'])) {
+ $field['unique_title'] = $fieldSpec['unique_title'];
+ }
+ if (!empty($fieldSpec['deprecated'])) {
+ $field['deprecated'] = TRUE;
+ }
+ if (!empty($fieldSpec['input_attrs'])) {
+ $field['html'] = \CRM_Utils_Array::rekey($fieldSpec['input_attrs'], function($str) {
+ return \CRM_Utils_String::convertStringToCamel($str, FALSE);
+ });
+ }
+ if (!empty($fieldSpec['input_type'])) {
+ $field['html']['type'] = $fieldSpec['input_type'];
+ }
+ if (!empty($fieldSpec['pseudoconstant'])) {
+ $field['pseudoconstant'] = \CRM_Utils_Array::rekey($fieldSpec['pseudoconstant'], function($str) {
+ return \CRM_Utils_String::convertStringToCamel($str, FALSE);
+ });
+ if (!isset($field['pseudoconstant']['optionEditPath']) && !empty($field['pseudoconstant']['optionGroupName'])) {
+ $field['pseudoconstant']['optionEditPath'] = 'civicrm/admin/options/' . $field['pseudoconstant']['optionGroupName'];
+ }
+ }
+ if (!empty($fieldSpec['primary_key']) || !empty($fieldSpec['readonly'])) {
+ $field['readonly'] = TRUE;
+ }
+ $field['add'] = $fieldSpec['add'] ?? NULL;
+ $fields[$fieldName] = $field;
+ }
+ \CRM_Core_DAO_AllCoreTables::invoke(static::class, 'fields_callback', $fields);
+ return $fields;
+ }
+
+ private static function getFieldLength($sqlType): ?string {
+ $open = strpos($sqlType, '(');
+ if ($open) {
+ return substr($sqlType, $open + 1, -1);
+ }
+ return NULL;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function indices(bool $localize = TRUE): array {
+ $definition = static::getEntityDefinition();
+ $indices = [];
+ if (isset($definition['getIndices'])) {
+ $fields = $definition['getFields']();
+ foreach ($definition['getIndices']() as $name => $info) {
+ $index = [
+ 'name' => $name,
+ 'field' => [],
+ 'localizable' => FALSE,
+ ];
+ foreach ($info['fields'] as $fieldName => $length) {
+ if (!empty($fields[$fieldName]['localizable'])) {
+ $index['localizable'] = TRUE;
+ }
+ if (is_int($length)) {
+ $fieldName .= "($length)";
+ }
+ $index['field'][] = $fieldName;
+ }
+ if (!empty($info['unique'])) {
+ $index['unique'] = TRUE;
+ }
+ $index['sig'] = ($definition['table']) . '::' . intval($info['unique'] ?? 0) . '::' . implode('::', $index['field']);
+ $indices[$name] = $index;
+ }
+ }
+ return ($localize && $indices) ? \CRM_Core_DAO_AllCoreTables::multilingualize(static::class, $indices) : $indices;
+ }
+
+ public static function getEntityDefinition(): array {
+ if (!isset(\Civi::$statics[static::class]['definition'])) {
+ $class = new \ReflectionClass(static::class);
+ $file = substr(basename($class->getFileName()), 0, -4) . '.entityType.php';
+ $folder = dirname($class->getFileName(), 4) . '/schema/';
+ $path = $folder . $file;
+ \Civi::$statics[static::class]['definition'] = include $path;
+ }
+ return \Civi::$statics[static::class]['definition'];
+ }
+
+ private static function getEntityInfo(): array {
+ return static::getEntityDefinition()['getInfo']();
+ }
+
+ private static function getDefaultSize($length) {
+ // Infer from tag if was not explicitly set or was invalid
+ // This map is slightly different from CRM_Core_Form_Renderer::$_sizeMapper
+ // Because we usually want fields to render as smaller than their maxlength
+ $sizes = [
+ 2 => 'TWO',
+ 4 => 'FOUR',
+ 6 => 'SIX',
+ 8 => 'EIGHT',
+ 16 => 'TWELVE',
+ 32 => 'MEDIUM',
+ 64 => 'BIG',
+ ];
+ foreach ($sizes as $size => $name) {
+ if ($length <= $size) {
+ return "CRM_Utils_Type::$name";
+ }
+ }
+ return 'CRM_Utils_Type::HUGE';
+ }
+
+ private static function getCrmTypeFromSqlType(string $sqlType): int {
+ [$type] = explode('(', $sqlType);
+ switch ($type) {
+ case 'varchar':
+ case 'char':
+ return \CRM_Utils_Type::T_STRING;
+
+ case 'datetime':
+ return \CRM_Utils_Type::T_DATE + \CRM_Utils_Type::T_TIME;
+
+ case 'decimal':
+ return \CRM_Utils_Type::T_MONEY;
+
+ case 'double':
+ return \CRM_Utils_Type::T_FLOAT;
+
+ case 'int unsigned':
+ case 'tinyint':
+ return \CRM_Utils_Type::T_INT;
+
+ default:
+ return constant('CRM_Utils_Type::T_' . strtoupper($type));
+ }
+ }
+
+ private static function getDAONameForEntity($entity) {
+ if (is_callable(['CRM_Core_DAO_AllCoreTables', 'getDAONameForEntity'])) {
+ return \CRM_Core_DAO_AllCoreTables::getDAONameForEntity($entity);
+ }
+ else {
+ return \CRM_Core_DAO_AllCoreTables::getFullName($entity);
+ }
+ }
+
+};
diff --git a/mixin/lib/civimix-schema@5.93.0/src/SchemaHelper.php b/mixin/lib/civimix-schema@5.93.0/src/SchemaHelper.php
new file mode 100644
index 00000000..57548052
--- /dev/null
+++ b/mixin/lib/civimix-schema@5.93.0/src/SchemaHelper.php
@@ -0,0 +1,179 @@
+key = $key;
+ }
+
+ public function install(): void {
+ $this->runSqls([$this->generateInstallSql()]);
+ }
+
+ public function uninstall(): void {
+ $this->runSqls([$this->generateUninstallSql()]);
+ }
+
+ public function generateInstallSql(): ?string {
+ return $this->getSqlGenerator()->getCreateTablesSql();
+ }
+
+ public function generateUninstallSql(): string {
+ return $this->getSqlGenerator()->getDropTablesSql();
+ }
+
+ public function hasSchema(): bool {
+ return file_exists($this->getExtensionDir() . '/schema');
+ }
+
+ /**
+ * @param string $entityName
+ * @return string|null
+ */
+ public function getTableName(string $entityName): ?string {
+ // Legacy compatability with CiviCRM < 5.74
+ if (!method_exists('Civi', 'entity')) {
+ return \CRM_Core_DAO_AllCoreTables::getTableForEntityName($entityName);
+ }
+ return \Civi::entity($entityName)->getMeta('table');
+ }
+
+ public function tableExists(string $tableName): bool {
+ return \CRM_Core_DAO::checkTableExists($tableName);
+ }
+
+ /**
+ * @param string $entityName
+ * @param string $fieldName
+ * @return bool
+ */
+ public function schemaFieldExists(string $entityName, string $fieldName): bool {
+ return \CRM_Core_BAO_SchemaHandler::checkIfFieldExists($this->getTableName($entityName), $fieldName, FALSE);
+ }
+
+ /**
+ * Converts an entity or field definition to SQL statement.
+ *
+ * @param array $defn
+ * The definition array, which can either represent
+ * an entity with fields or a single database column.
+ * @return string
+ * The generated SQL statement, which is either an SQL command
+ * for creating a table with constraints or for defining a single column.
+ */
+ public function arrayToSql(array $defn): string {
+ $generator = $this->getSqlGenerator();
+ // Entity array: generate entire table
+ if (isset($defn['getFields'])) {
+ return $generator->generateCreateTableWithConstraintSql($defn);
+ }
+ // Field array: generate single column
+ else {
+ return $generator->generateFieldSql($defn);
+ }
+ }
+
+ /**
+ * Create table (if not exists) from a given php schema file.
+ *
+ * The original entityType.php file should be copied to a directory (e.g. `my_extension/upgrade/schema`)
+ * and prefixed with the version-added.
+ *
+ * @param string $filePath
+ * Relative path to copied schema file (relative to extension directory).
+ * @return bool
+ * @throws \CRM_Core_Exception
+ */
+ public function createEntityTable(string $filePath): bool {
+ $absolutePath = $this->getExtensionDir() . DIRECTORY_SEPARATOR . $filePath;
+ $entityDefn = include $absolutePath;
+ $sql = $this->arrayToSql($entityDefn);
+ \CRM_Core_DAO::executeQuery($sql, [], TRUE, NULL, FALSE, FALSE);
+ return TRUE;
+ }
+
+ /**
+ * Task to add or change a column definition, based on the php schema spec.
+ *
+ * @param string $entityName
+ * @param string $fieldName
+ * @param array $fieldSpec
+ * As definied in the .entityType.php file for $entityName
+ * @param string|null $position
+ * E.g. "AFTER `another_column_name`" or "FIRST"
+ * @return bool
+ * @throws \CRM_Core_Exception
+ */
+ public function alterSchemaField(string $entityName, string $fieldName, array $fieldSpec, ?string $position = NULL): bool {
+ $tableName = $this->getTableName($entityName);
+ $fieldSql = $this->arrayToSql($fieldSpec);
+ if ($position) {
+ $fieldSql .= " $position";
+ }
+ if ($this->schemaFieldExists($entityName, $fieldName)) {
+ $query = "ALTER TABLE `$tableName` CHANGE `$fieldName` `$fieldName` $fieldSql";
+ }
+ else {
+ $query = "ALTER TABLE `$tableName` ADD COLUMN `$fieldName` $fieldSql";
+ }
+ \CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE);
+ return TRUE;
+ }
+
+ public function dropSchemaField(string $entityName, string $fieldName): bool {
+ if ($this->schemaFieldExists($entityName, $fieldName)) {
+ $tableName = $this->getTableName($entityName);
+ \CRM_Core_DAO::executeQuery("ALTER TABLE `$tableName` DROP COLUMN `$fieldName`", [], TRUE, NULL, FALSE, FALSE);
+ }
+ return TRUE;
+ }
+
+ public function dropTable(string $tableName): bool {
+ \CRM_Core_BAO_SchemaHandler::dropTable($tableName);
+ return TRUE;
+ }
+
+ /**
+ * @param array $sqls
+ * List of SQL scripts.
+ */
+ private function runSqls(array $sqls): void {
+ foreach ($sqls as $sql) {
+ \CRM_Utils_File::runSqlQuery(CIVICRM_DSN, $sql);
+ }
+ }
+
+ protected function getExtensionDir(): string {
+ if ($this->key === 'civicrm') {
+ $r = new \ReflectionClass('CRM_Core_ClassLoader');
+ return dirname($r->getFileName(), 3);
+ }
+ $system = \CRM_Extension_System::singleton();
+ return $system->getMapper()->keyToBasePath($this->key);
+ }
+
+ private function getSqlGenerator() {
+ if ($this->sqlGenerator === NULL) {
+ $gen = require __DIR__ . '/SqlGenerator.php';
+ $this->sqlGenerator = $gen::createFromFolder($this->key, $this->getExtensionDir() . '/schema', $this->key === 'civicrm');
+ }
+ return $this->sqlGenerator;
+ }
+
+};
diff --git a/mixin/lib/civimix-schema@5.93.0/src/SchemaHelperInterface.php b/mixin/lib/civimix-schema@5.93.0/src/SchemaHelperInterface.php
new file mode 100644
index 00000000..826617b0
--- /dev/null
+++ b/mixin/lib/civimix-schema@5.93.0/src/SchemaHelperInterface.php
@@ -0,0 +1,44 @@
+entities = array_filter($entities, function($entity) {
+ return !empty($entity['table']);
+ });
+ $this->findExternalTable = $findExternalTable ?: function() {
+ return NULL;
+ };
+ }
+
+ public function getEntities(): array {
+ return $this->entities;
+ }
+
+ public function getCreateTablesSql(): string {
+ $sql = '';
+ foreach ($this->entities as $entity) {
+ $sql .= $this->generateCreateTableSql($entity);
+ }
+ foreach ($this->entities as $entity) {
+ $sql .= $this->generateConstraintsSql($entity);
+ }
+ return $sql;
+ }
+
+ public function getCreateTableSql(string $entityName): string {
+ $sql = $this->generateCreateTableSql($this->entities[$entityName]);
+ $sql .= $this->generateConstraintsSql($this->entities[$entityName]);
+ return $sql;
+ }
+
+ public function getDropTablesSql(): string {
+ $sql = "SET FOREIGN_KEY_CHECKS=0;\n";
+ foreach ($this->entities as $entity) {
+ $sql .= "DROP TABLE IF EXISTS `{$entity['table']}`;\n";
+ }
+ $sql .= "SET FOREIGN_KEY_CHECKS=1;\n";
+ return $sql;
+ }
+
+ public function generateCreateTableWithConstraintSql(array $entity): string {
+ $definition = $this->getTableDefinition($entity);
+ $constraints = $this->getTableConstraints($entity);
+ $sql = "CREATE TABLE IF NOT EXISTS `{$entity['table']}` (\n " .
+ implode(",\n ", $definition);
+ if ($constraints) {
+ $sql .= ",\n " . implode(",\n ", $constraints);
+ }
+ $sql .= "\n)\n" . $this->getTableOptions() . ";\n";
+ return $sql;
+ }
+
+ private function generateCreateTableSql(array $entity): string {
+ $definition = $this->getTableDefinition($entity);
+ $sql = "CREATE TABLE IF NOT EXISTS `{$entity['table']}` (\n " .
+ implode(",\n ", $definition) .
+ "\n)\n" .
+ $this->getTableOptions() . ";\n";
+ return $sql;
+ }
+
+ private function getTableDefinition(array $entity): array {
+ $definition = [];
+ $primaryKeys = [];
+ foreach ($entity['getFields']() as $fieldName => $field) {
+ if (!empty($field['primary_key'])) {
+ $primaryKeys[] = "`$fieldName`";
+ }
+ $definition[] = "`$fieldName` " . self::generateFieldSql($field);
+ }
+ if ($primaryKeys) {
+ $definition[] = 'PRIMARY KEY (' . implode(', ', $primaryKeys) . ')';
+ }
+ $indices = isset($entity['getIndices']) ? $entity['getIndices']() : [];
+ foreach ($indices as $indexName => $index) {
+ $indexFields = [];
+ foreach ($index['fields'] as $fieldName => $length) {
+ $indexFields[] = "`$fieldName`" . (is_int($length) ? "($length)" : '');
+ }
+ $definition[] = (!empty($index['unique']) ? 'UNIQUE ' : '') . "INDEX `$indexName`(" . implode(', ', $indexFields) . ')';
+ }
+ return $definition;
+ }
+
+ private function generateConstraintsSql(array $entity): string {
+ $constraints = $this->getTableConstraints($entity);
+ $sql = '';
+ if ($constraints) {
+ $sql .= "ALTER TABLE `{$entity['table']}`\n ";
+ $sql .= 'ADD ' . implode(",\n ADD ", $constraints) . ";\n";
+ }
+ return $sql;
+ }
+
+ private function getTableConstraints(array $entity): array {
+ $constraints = [];
+ foreach ($entity['getFields']() as $fieldName => $field) {
+ // `entity_reference.fk` defaults to TRUE if not set. If FALSE, do not add constraint.
+ if (!empty($field['entity_reference']['entity']) && ($field['entity_reference']['fk'] ?? TRUE)) {
+ $fkName = \CRM_Core_BAO_SchemaHandler::getIndexName($entity['table'], $fieldName);
+ // Make sure the FK does not already exist...
+ CRM_Core_BAO_SchemaHandler::safeRemoveFK($entity['table'], 'FK_' . $fkName);
+ $constraint = "CONSTRAINT `FK_$fkName` FOREIGN KEY (`$fieldName`)" .
+ " REFERENCES `" . $this->getTableForEntity($field['entity_reference']['entity']) . "`(`{$field['entity_reference']['key']}`)";
+ if (!empty($field['entity_reference']['on_delete'])) {
+ $constraint .= " ON DELETE {$field['entity_reference']['on_delete']}";
+ }
+ $constraints[] = $constraint;
+ }
+ }
+ return $constraints;
+ }
+
+ public static function generateFieldSql(array $field): string {
+ $fieldSql = $field['sql_type'];
+ if (!empty($field['collate'])) {
+ $fieldSql .= " COLLATE {$field['collate']}";
+ }
+ // Required fields and booleans cannot be null
+ // FIXME: For legacy support this doesn't force boolean fields to be NOT NULL... but it really should.
+ if (!empty($field['required'])) {
+ $fieldSql .= ' NOT NULL';
+ }
+ else {
+ $fieldSql .= ' NULL';
+ }
+ if (!empty($field['auto_increment'])) {
+ $fieldSql .= " AUTO_INCREMENT";
+ }
+ $fieldSql .= self::getDefaultSql($field);
+ if (!empty($field['description'])) {
+ $fieldSql .= " COMMENT '" . \CRM_Core_DAO::escapeString($field['description']) . "'";
+ }
+ return $fieldSql;
+ }
+
+ private static function getDefaultSql(array $field): string {
+ // Booleans always have a default
+ if ($field['sql_type'] === 'boolean') {
+ $field += ['default' => FALSE];
+ }
+ if (!array_key_exists('default', $field)) {
+ return '';
+ }
+ if (is_null($field['default'])) {
+ $default = 'NULL';
+ }
+ elseif (is_bool($field['default'])) {
+ $default = $field['default'] ? 'TRUE' : 'FALSE';
+ }
+ elseif (!is_string($field['default']) || str_starts_with($field['default'], 'CURRENT_TIMESTAMP')) {
+ $default = $field['default'];
+ }
+ else {
+ $default = "'" . \CRM_Core_DAO::escapeString($field['default']) . "'";
+ }
+ return ' DEFAULT ' . $default;
+ }
+
+ private function getTableForEntity(string $entityName): string {
+ return $this->entities[$entityName]['table'] ?? call_user_func($this->findExternalTable, $entityName);
+ }
+
+ /**
+ * Get general/default options for use in CREATE TABLE (eg character set, collation).
+ */
+ private function getTableOptions(): string {
+ if (!Civi\Core\Container::isContainerBooted()) {
+ // Pre-installation environment ==> aka new install
+ $collation = CRM_Core_BAO_SchemaHandler::DEFAULT_COLLATION;
+ }
+ else {
+ // What character-set is used for CiviCRM core schema? What collation?
+ // This depends on when the DB was *initialized*:
+ // - civicrm-core >= 5.33 has used `CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci`
+ // - civicrm-core 4.3-5.32 has used `CHARACTER SET utf8 COLLATE utf8_unicode_ci`
+ // - civicrm-core <= 4.2 -- I haven't checked, but it's probably the same.
+ // Some systems have migrated (eg APIv3's `System.utf8conversion`), but (as of Feb 2024)
+ // we haven't made any effort to push to this change.
+ $collation = \CRM_Core_BAO_SchemaHandler::getInUseCollation();
+ }
+
+ $characterSet = (stripos($collation, 'utf8mb4') !== FALSE) ? 'utf8mb4' : 'utf8';
+ return "ENGINE=InnoDB DEFAULT CHARACTER SET {$characterSet} COLLATE {$collation} ROW_FORMAT=DYNAMIC";
+ }
+
+};
diff --git a/mixin/lib/pathload-0.php b/mixin/lib/pathload-0.php
deleted file mode 100644
index 76d64254..00000000
--- a/mixin/lib/pathload-0.php
+++ /dev/null
@@ -1,711 +0,0 @@
-top = $top;
- }
- public function offsetExists($version): bool {
- return ($version === 'top' || $version <= $this->top->version);
- }
- public function offsetGet($version): ?\PathLoadInterface {
- if ($version === 'top' || $version <= $this->top->version) {
- return $this->top;
- }
- return NULL;
- }
- public function offsetSet($offset, $value): void {
- error_log("Cannot overwrite PathLoad[$offset]");
- }
- public function offsetUnset($offset): void {
- error_log("Cannot remove PathLoad[$offset]");
- }
- }
- class Package {
- /**
- * Split a package identifier into its parts.
- *
- * @param string $package
- * Ex: 'foobar@1.2.3'
- * @return array
- * Tuple: [$majorName, $name, $version]
- * Ex: 'foobar@1', 'foobar', '1.2.3'
- */
- public static function parseExpr(string $package): array {
- if (strpos($package, '@') === FALSE) {
- throw new \RuntimeException("Malformed package name: $package");
- }
- [$prefix, $suffix] = explode('@', $package, 2);
- $prefix = str_replace('/', '~', $prefix);
- [$major] = explode('.', $suffix, 2);
- return ["$prefix@$major", $prefix, $suffix];
- }
- public static function parseFileType(string $file): array {
- if (substr($file, -4) === '.php') {
- return ['php', substr(basename($file), 0, -4)];
- }
- elseif (substr($file, '-5') === '.phar') {
- return ['phar', substr(basename($file), 0, -5)];
- }
- elseif (is_dir($file)) {
- return ['dir', basename($file)];
- }
- else {
- return [NULL, NULL];
- }
- }
- /**
- * @param string $file
- * Ex: '/var/www/app-1/lib/foobar@.1.2.3.phar'
- * @return \PathLoad\Vn\Package|null
- */
- public static function create(string $file): ?Package {
- [$type, $base] = self::parseFileType($file);
- if ($type === NULL) {
- return NULL;
- }
- $self = new Package();
- [$self->majorName, $self->name, $self->version] = static::parseExpr($base);
- $self->file = $file;
- $self->type = $type;
- return $self;
- }
- /**
- * @var string
- * Ex: '/var/www/app-1/lib/cloud-file-io@1.2.3.phar'
- */
- public $file;
- /**
- * @var string
- * Ex: 'cloud-file-io'
- */
- public $name;
- /**
- * @var string
- * Ex: 'cloud-file-io@1'
- */
- public $majorName;
- /**
- * @var string
- * Ex: '1.2.3'
- */
- public $version;
- /**
- * @var string
- * Ex: 'php' or 'phar' or 'dir'
- */
- public $type;
- public $reloadable = FALSE;
- }
- class Scanner {
- /**
- * @var array
- * Array(string $id => [package => string, glob => string])
- * @internal
- */
- public $allRules = [];
- /**
- * @var array
- * Array(string $id => [package => string, glob => string])
- * @internal
- */
- public $newRules = [];
- /**
- * @param array $rule
- * Ex: ['package' => '*', 'glob' => '/var/www/lib/*@*']
- * Ex: ['package' => 'cloud-file-io@1', 'glob' => '/var/www/lib/cloud-io@1*.phar'])
- * @return void
- */
- public function addRule(array $rule): void {
- $id = static::id($rule);
- $this->newRules[$id] = $this->allRules[$id] = $rule;
- }
- public function reset(): void {
- $this->newRules = $this->allRules;
- }
- /**
- * Evaluate any rules that have a chance of finding $packageHint.
- *
- * @param string $packageHint
- * Give a hint about what package we're looking for.
- * The scanner will try to target packages based on this hint.
- * Ex: '*' or 'cloud-file-io'
- * @return \Generator
- * A list of packages. These may not be the exact package you're looking for.
- * You should assimilate knowledge of all outputs because you may not get them again.
- */
- public function scan(string $packageHint): \Generator {
- yield from [];
- foreach (array_keys($this->newRules) as $id) {
- $searchRule = $this->newRules[$id];
- if ($searchRule['package'] === '*' || $searchRule['package'] === $packageHint) {
- unset($this->newRules[$id]);
- if (isset($searchRule['glob'])) {
- foreach ((array) glob($searchRule['glob']) as $file) {
- if (($package = Package::create($file)) !== NULL) {
- yield $package;
- }
- }
- }
- if (isset($searchRule['file'])) {
- $package = new Package();
- $package->file = $searchRule['file'];
- $package->name = $searchRule['package'];
- $package->majorName = $searchRule['package'] . '@' . explode('.', $searchRule['version'])[0];
- $package->version = $searchRule['version'];
- $package->type = $searchRule['type'] ?: Package::parseFileType($searchRule['file'])[0];
- yield $package;
- }
- }
- }
- }
- protected static function id(array $rule): string {
- if (isset($rule['glob'])) {
- return $rule['glob'];
- }
- elseif (isset($rule['file'])) {
- return md5(implode(' ', [$rule['file'], $rule['package'], $rule['version']]));
- }
- else {
- throw new \RuntimeException("Cannot identify rule: " . json_encode($rule));
- }
- }
- }
- class Psr0Loader {
- /**
- * @var array
- * Ex: $paths['F']['Foo_'][0] = '/var/www/app/lib/foo@1.0.0/src/';
- * @internal
- */
- public $paths = [];
- /**
- * @param string $dir
- * @param array $config
- * Ex: ['Foo_' => ['src/']] or ['Foo_' => ['Foo_']]
- */
- public function addAll(string $dir, array $config) {
- $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
- foreach ($config as $prefix => $relPaths) {
- $bucket = $prefix[0];
- foreach ((array) $relPaths as $relPath) {
- $this->paths[$bucket][$prefix][] = $dir . $relPath;
- }
- }
- }
- /**
- * Loads the class file for a given class name.
- *
- * @param string $class The fully-qualified class name.
- * @return mixed The mapped file name on success, or boolean false on failure.
- */
- public function loadClass(string $class) {
- $bucket = $class[0];
- if (!isset($this->paths[$bucket])) {
- return FALSE;
- }
- $file = DIRECTORY_SEPARATOR . str_replace(['_', '\\'], [DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR], $class) . '.php';
- foreach ($this->paths[$bucket] as $prefix => $paths) {
- if ($prefix === substr($class, 0, strlen($prefix))) {
- foreach ($paths as $path) {
- $fullFile = $path . $file;
- if (file_exists($fullFile)) {
- doRequire($fullFile);
- return $fullFile;
- }
- }
- }
- }
- return FALSE;
- }
- }
- class Psr4Loader {
- /**
- * @var array
- * Ex: $prefixes['Foo\\'][0] = '/var/www/app/lib/foo@1.0.0/src/']
- * @internal
- */
- public $prefixes = [];
- public function addAll(string $dir, array $config) {
- foreach ($config as $prefix => $relPaths) {
- foreach ($relPaths as $relPath) {
- $this->addNamespace($prefix, $dir . '/' . $relPath);
- }
- }
- }
- /**
- * Adds a base directory for a namespace prefix.
- *
- * @param string $prefix
- * The namespace prefix.
- * @param string $baseDir
- * A base directory for class files in the namespace.
- * @return void
- */
- private function addNamespace($prefix, $baseDir) {
- $prefix = trim($prefix, '\\') . '\\';
- $baseDir = rtrim($baseDir, DIRECTORY_SEPARATOR) . '/';
- if (isset($this->prefixes[$prefix]) === FALSE) {
- $this->prefixes[$prefix] = [];
- }
- array_push($this->prefixes[$prefix], $baseDir);
- }
- /**
- * Loads the class file for a given class name.
- *
- * @param string $class The fully-qualified class name.
- * @return mixed The mapped file name on success, or boolean false on failure.
- */
- public function loadClass(string $class) {
- $prefix = $class;
- while (FALSE !== $pos = strrpos($prefix, '\\')) {
- $prefix = substr($class, 0, $pos + 1);
- $relativeClass = substr($class, $pos + 1);
- if ($mappedFile = $this->findRelativeClass($prefix, $relativeClass)) {
- doRequire($mappedFile);
- return $mappedFile;
- }
- $prefix = rtrim($prefix, '\\');
- }
- return FALSE;
- }
- /**
- * Load the mapped file for a namespace prefix and relative class.
- *
- * @param string $prefix
- * The namespace prefix.
- * @param string $relativeClass
- * The relative class name.
- * @return string|FALSE
- * Matched file name, or FALSE if none found.
- */
- private function findRelativeClass($prefix, $relativeClass) {
- if (isset($this->prefixes[$prefix]) === FALSE) {
- return FALSE;
- }
- $relFile = str_replace('\\', DIRECTORY_SEPARATOR, $relativeClass) . '.php';
- foreach ($this->prefixes[$prefix] as $baseDir) {
- $file = $baseDir . $relFile;
- if (file_exists($file)) {
- return $file;
- }
- }
- return FALSE;
- }
- }
- class PathLoad implements \PathLoadInterface {
- /**
- * @var null|int
- */
- public $version;
- /**
- * @var Scanner
- * @internal
- */
- public $scanner;
- /**
- * List of best-known versions for each package.
- *
- * Packages are loaded lazily. Once loaded, the data is moved to $loadedPackages.
- *
- * @var Package[]
- * Ex: ['cloud-file-io@1' => new Package('/usr/share/php-pathload/cloud-file-io@1.2.3.phar',
- * ...)]
- * @internal
- */
- public $availablePackages = [];
- /**
- * List of packages that have already been resolved.
- *
- * @var Package[]
- * Ex: ['cloud-file-io@1' => new Package('/usr/share/php-pathload/cloud-file-io@1.2.3.phar',
- * ...)] Note: If PathLoad version is super-ceded, then the loadedPackages may be instances of
- * an old `Package` class. Be mindful of duck-type compatibility. We don't strictly need to
- * retain this data, but it feels it'd be handy for debugging.
- * @internal
- */
- public $loadedPackages = [];
- /**
- * Log of package activations. Used to re-initialize class-loader if we upgrade.
- *
- * @var array
- * @internal
- */
- public $activatedPackages = [];
- /**
- * List of hints for class-loading. If someone tries to use a matching class, then
- * load the corresponding package.
- *
- * Namespace-rules are evaluated lazily. Once evaluated, the data is removed.
- *
- * @var array
- * Array(string $prefix => [string $package => string $package])
- * Ex: ['Super\Cloud\IO\' => ['cloud-io@1' => 'cloud-io@1']
- * @internal
- */
- public $availableNamespaces;
- /**
- * @var \PathLoad\Vn\Psr0Loader
- * @internal
- */
- public $psr0;
- /**
- * @var \PathLoad\Vn\Psr4Loader
- * @internal
- */
- public $psr4;
- /**
- * @param int $version
- * Identify the version being instantiated.
- * @param \PathLoadInterface|null $old
- * If this instance is a replacement for an older instance, then it will be passed in.
- * @return \ArrayAccess
- * Versioned work-a-like array.
- */
- public static function create(int $version, ?\PathLoadInterface $old = NULL) {
- if ($old !== NULL) {
- $old->unregister();
- }
- $new = new static();
- $new->version = $version;
- $new->scanner = new Scanner();
- $new->psr0 = new Psr0Loader();
- $new->psr4 = new Psr4Loader();
- $new->register();
- // The exact protocol for assimilating $old instances may need change.
- // This seems like a fair guess as long as old properties are forward-compatible.
-
- if ($old === NULL) {
- $baseDirs = getenv('PHP_PATHLOAD') ? explode(PATH_SEPARATOR, getenv('PHP_PATHLOAD')) : [];
- foreach ($baseDirs as $baseDir) {
- $new->addSearchDir($baseDir);
- }
- }
- else {
- // TIP: You might use $old->version to decide what to use.
- foreach ($old->scanner->allRules as $rule) {
- $new->scanner->addRule($rule);
- }
- $new->loadedPackages = $old->loadedPackages;
- $new->availableNamespaces = $old->availableNamespaces;
- foreach ($old->activatedPackages as $activatedPackage) {
- $new->activatePackage($activatedPackage['name'], $activatedPackage['dir'], $activatedPackage['config']);
- }
- }
- return new Versions($new);
- }
- public function register(): \PathLoadInterface {
- spl_autoload_register([$this, 'loadClass']);
- return $this;
- }
- public function unregister(): \PathLoadInterface {
- spl_autoload_unregister([$this, 'loadClass']);
- return $this;
- }
- public function reset(): \PathLoadInterface {
- $this->scanner->reset();
- return $this;
- }
- /**
- * Append a directory (with many packages) to the search-path.
- *
- * @param string $baseDir
- * The path to a base directory (e.g. `/var/www/myapp/lib`) which contains many packages (e.g.
- * `foo@1.2.3.phar` or `bar@4.5.6/autoload.php`).
- */
- public function addSearchDir(string $baseDir): \PathLoadInterface {
- $this->scanner->addRule(['package' => '*', 'glob' => "$baseDir/*@*"]);
- return $this;
- }
- /**
- * Append one specific item to the search list.
- *
- * @param string $name
- * Ex: 'cloud-file-io'
- * @param string $version
- * Ex: '1.2.3'
- * @param string $file
- * Full path to the file or folder.
- * @param string|null $type
- * One of: 'php', 'phar', or 'dir'. NULL will auto-detect.
- *
- * @return \PathLoadInterface
- */
- public function addSearchItem(string $name, string $version, string $file, ?string $type = NULL): \PathLoadInterface {
- $this->scanner->addRule(['package' => $name, 'version' => $version, 'file' => $file, 'type' => $type]);
- return $this;
- }
- /**
- * Add auto-loading hints. If someone requests a class in $namespace, then we load $package.
- *
- * Consecutive/identical calls to addNamespace() are de-duplicated.
- *
- * @param string $package
- * Ex: 'cloud-io@1'
- * @param string|string[] $namespaces
- * Ex: 'Super\Cloud\IO\'
- */
- public function addNamespace(string $package, $namespaces): \PathLoadInterface {
- foreach ((array) $namespaces as $namespace) {
- $this->availableNamespaces[$namespace][$package] = $package;
- }
- return $this;
- }
- public function loadClass(string $class) {
- if (strpos($class, '\\') !== FALSE) {
- $this->loadPackagesByNamespace('\\', explode('\\', $class));
- }
- elseif (strpos($class, '_') !== FALSE) {
- $this->loadPackagesByNamespace('_', explode('_', $class));
- }
- return $this->psr4->loadClass($class) || $this->psr0->loadClass($class);
- }
- /**
- * If the application requests class "Foo\Bar\Whiz\Bang", then you should load
- * any packages related to "Foo\*", "Foo\Bar\*", or "Foo\Bar\Whiz\*".
- *
- * @param string $delim
- * Ex: '\\' or '_'
- * @param string[] $classParts
- * Ex: ['Symfony', 'Components', 'Filesystem', 'Filesystem']
- */
- private function loadPackagesByNamespace(string $delim, array $classParts): void {
- array_pop($classParts);
- do {
- $foundPackages = FALSE;
- $namespace = '';
- foreach ($classParts as $nsPart) {
- $namespace .= $nsPart . $delim;
- if (isset($this->availableNamespaces[$namespace])) {
- $packages = $this->availableNamespaces[$namespace];
- foreach ($packages as $package) {
- unset($this->availableNamespaces[$namespace][$package]);
- if ($this->loadPackage($package)) {
- $foundPackages = TRUE;
- }
- else {
- trigger_error("PathLoad: Failed to locate package \"$package\" required for namespace \"$namespace\"", E_USER_WARNING);
- $this->availableNamespaces[$namespace][$package] = $package; /* Maybe some other time */
- }
- }
- }
- }
- } while ($foundPackages);
- // Loading a package could produce metadata about other packages. Assimilate those too.
- }
- /**
- * Load the content of a package.
- *
- * @param string $majorName
- * Ex: 'cloud-io@1'
- * @param bool $reload
- * @return string|NULL
- * The version# of the loaded package. Otherwise, NULL
- */
- public function loadPackage(string $majorName, bool $reload = FALSE): ?string {
- if (isset($this->loadedPackages[$majorName])) {
- if ($reload && $this->loadedPackages[$majorName]->reloadable) {
- $this->scanner->reset();
- }
- else {
- if ($reload) {
- trigger_error("PathLoad: Declined to reload \"$majorName\". Package is not reloadable.", E_USER_WARNING);
- }
- return $this->loadedPackages[$majorName]->version;
- }
- }
- $this->scanAvailablePackages(explode('@', $majorName, 2)[0], $this->availablePackages);
- if (!isset($this->availablePackages[$majorName])) {
- return NULL;
- }
- $package = $this->loadedPackages[$majorName] = $this->availablePackages[$majorName];
- unset($this->availablePackages[$majorName]);
- switch ($package->type ?? NULL) {
- case 'php':
- doRequire($package->file);
- return $package->version;
- case 'phar':
- doRequire($package->file);
- $this->useMetadataFiles($package, 'phar://' . $package->file);
- return $package->version;
- case 'dir':
- $this->useMetadataFiles($package, $package->file);
- return $package->version;
- default:
- \error_log("PathLoad: Package (\"$majorName\") appears malformed.");
- return NULL;
- }
- }
- private function scanAvailablePackages(string $hint, array &$avail): void {
- foreach ($this->scanner->scan($hint) as $package) {
- /** @var Package $package */
- if (!isset($avail[$package->majorName]) || \version_compare($package->version, $avail[$package->majorName]->version, '>')) {
- $avail[$package->majorName] = $package;
- }
- }
- }
- /**
- * When loading a package, execute metadata files like "pathload.main.php" or "pathload.json".
- *
- * @param Package $package
- * @param string $dir
- * Ex: '/var/www/lib/cloud-io@1.2.0'
- * Ex: 'phar:///var/www/lib/cloud-io@1.2.0.phar'
- */
- private function useMetadataFiles(Package $package, string $dir): void {
- $phpFile = "$dir/pathload.main.php";
- $jsonFile = "$dir/pathload.json";
- if (file_exists($phpFile)) {
- require $phpFile;
- }
- elseif (file_exists($jsonFile)) {
- $jsonData = json_decode(file_get_contents($jsonFile), TRUE);
- $id = $package->name . '@' . $package->version;
- $this->activatePackage($id, $dir, $jsonData);
- }
- }
- /**
- * Given a configuration for the package, activate the correspond autoloader rules.
- *
- * @param string $majorName
- * Ex: 'cloud-io@1'
- * @param string|null $dir
- * Used for applying the 'autoload' rules.
- * Ex: '/var/www/lib/cloud-io@1.2.3'
- * @param array $config
- * Ex: ['autoload' => ['psr4' => ...], 'require-namespace' => [...], 'require-package' => [...]]
- * @return \PathLoadInterface
- */
- public function activatePackage(string $majorName, ?string $dir, array $config): \PathLoadInterface {
- if (isset($config['reloadable'])) {
- $this->loadedPackages[$majorName]->reloadable = $config['reloadable'];
- }
- if (!isset($config['autoload'])) {
- return $this;
- }
- if ($dir === NULL) {
- throw new \RuntimeException("Cannot activate package $majorName. The 'autoload' property requires a base-directory.");
- }
- $this->activatedPackages[] = ['name' => $majorName, 'dir' => $dir, 'config' => $config];
- if (!empty($config['autoload']['include'])) {
- foreach ($config['autoload']['include'] as $file) {
- doRequire($dir . DIRECTORY_SEPARATOR . $file);
- }
- }
- if (isset($config['autoload']['psr-0'])) {
- $this->psr0->addAll($dir, $config['autoload']['psr-0']);
- }
- if (isset($config['autoload']['psr-4'])) {
- $this->psr4->addAll($dir, $config['autoload']['psr-4']);
- }
- foreach ($config['require-namespace'] ?? [] as $nsRule) {
- foreach ((array) $nsRule['package'] as $package) {
- foreach ((array) $nsRule['prefix'] as $prefix) {
- $this->availableNamespaces[$prefix][$package] = $package;
- }
- }
- }
- foreach ($config['require-package'] ?? [] as $package) {
- $this->loadPackage($package);
- }
- return $this;
- }
- }
- }
-}
-
-namespace {
- // New or upgraded instance.
- $GLOBALS['_PathLoad'] = \PathLoad\V0\PathLoad::create(0, $GLOBALS['_PathLoad']['top'] ?? NULL);
- if (!function_exists('pathload')) {
- /**
- * Get a reference the PathLoad manager.
- *
- * @param int|string $version
- * @return \PathLoadInterface
- */
- function pathload($version = 'top') {
- return $GLOBALS['_PathLoad'][$version];
- }
- }
- return pathload();
-}
diff --git a/mixin/mgd-php@2.0.0.mixin.php b/mixin/mgd-php@2.0.0.mixin.php
new file mode 100644
index 00000000..54443bfb
--- /dev/null
+++ b/mixin/mgd-php@2.0.0.mixin.php
@@ -0,0 +1,67 @@
+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;
+ }
+
+ // Optimization: if managed entities were requested for specific module(s),
+ // check name and return early if not applicable.
+ if ($event->modules && !in_array($mixInfo->longName, $event->modules, TRUE)) {
+ return;
+ }
+
+ $path = $mixInfo->getPath();
+ $mgdFiles = array_merge(
+ (array) glob("$path/*.mgd.php"),
+ CRM_Utils_File::findFiles("$path/managed", '*.mgd.php'),
+ CRM_Utils_File::findFiles("$path/api", '*.mgd.php'),
+ CRM_Utils_File::findFiles("$path/CRM", '*.mgd.php'),
+ CRM_Utils_File::findFiles("$path/Civi", '*.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';
+ }
+ if (empty($e['source'])) {
+ $e['source'] = $file;
+ }
+ $event->entities[] = $e;
+ }
+ }
+ });
+
+};
diff --git a/mixin/smarty-v2@1.0.3.mixin.php b/mixin/smarty-v2@1.0.3.mixin.php
deleted file mode 100644
index f8718c8c..00000000
--- a/mixin/smarty-v2@1.0.3.mixin.php
+++ /dev/null
@@ -1,78 +0,0 @@
-getPath('templates');
- if (!file_exists($dir)) {
- return;
- }
-
- $register = function($newDirs) {
- $smarty = CRM_Core_Smarty::singleton();
- $v2 = isset($smarty->_version) && version_compare($smarty->_version, 3, '<');
- $templateDirs = (array) ($v2 ? $smarty->template_dir : $smarty->getTemplateDir());
- $templateDirs = array_merge($newDirs, $templateDirs);
- $templateDirs = array_unique(array_map(function($v) {
- $v = str_replace(DIRECTORY_SEPARATOR, '/', $v);
- $v = rtrim($v, '/') . '/';
- return $v;
- }, $templateDirs));
- if ($v2) {
- $smarty->template_dir = $templateDirs;
- }
- else {
- $smarty->setTemplateDir($templateDirs);
- }
- };
-
- // 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([$dir]);
- }
- 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([$dir]);
- return;
- }
-
- // Typical Pageview, Standard Loader: Defer the actual registration for a moment -- to ensure that Smarty is online.
- // We need to bundle-up all dirs -- Smarty 3/4/5 is inefficient with processing repeated calls to `getTemplateDir()`+`setTemplateDir()`
- if (!isset(Civi::$statics[__FILE__]['event'])) {
- Civi::$statics[__FILE__]['event'] = 'civi.smarty-v2.addPaths.' . md5(__FILE__);
- Civi::dispatcher()->addListener('hook_civicrm_config', function() use ($register) {
- $dirs = [];
- $event = \Civi\Core\Event\GenericHookEvent::create(['dirs' => &$dirs]);
- Civi::dispatcher()->dispatch(Civi::$statics[__FILE__]['event'], $event);
- $register($dirs);
- });
- }
-
- Civi::dispatcher()->addListener(Civi::$statics[__FILE__]['event'], function($event) use ($mixInfo, $dir) {
- if ($mixInfo->isActive()) {
- array_unshift($event->dirs, $dir);
- }
- });
-
-};
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 8a0289a6..8b267594 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -1774,89 +1774,89 @@ parameters:
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optiongroup_id_name_mapping\(\) has no return type specified\.$#'
+ message: '#^Loose comparison via "\=\=" is not allowed\.$#'
+ identifier: equal.notAllowed
+ count: 2
+ path: CRM/Banking/Helpers/OptionValue.php
+
+ -
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optiongroup_id_name_mapping\(\) has no return type specified\.$#'
identifier: missingType.return
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optiongroup_id_name_mapping\(\) has parameter \$group_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optiongroup_id_name_mapping\(\) has parameter \$group_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optiongroupid_by_name\(\) has parameter \$group_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optiongroupid_by_name\(\) has parameter \$group_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalue_by_groupname_and_name\(\) has parameter \$group_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalue_by_groupname_and_name\(\) has parameter \$group_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalue_by_groupname_and_name\(\) has parameter \$value_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalue_by_groupname_and_name\(\) has parameter \$value_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalue_by_name\(\) has parameter \$group_id with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalue_by_name\(\) has parameter \$group_id with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalue_by_name\(\) has parameter \$value_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalue_by_name\(\) has parameter \$value_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalueid_by_groupname_and_name\(\) has parameter \$group_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalueid_by_groupname_and_name\(\) has parameter \$group_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalueid_by_groupname_and_name\(\) has parameter \$value_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalueid_by_groupname_and_name\(\) has parameter \$value_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalueid_by_name\(\) has parameter \$group_id with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalueid_by_name\(\) has parameter \$group_id with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_optionvalueid_by_name\(\) has parameter \$value_name with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_optionvalueid_by_name\(\) has parameter \$value_name with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_tx_status_closed\(\) has parameter \$tx_status_id with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_tx_status_closed\(\) has parameter \$tx_status_id with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/OptionValue.php
-
- message: '#^Function banking_helper_tx_status_closed\(\) should return true but returns bool\.$#'
+ message: '#^Method CRM_Banking_Helpers_OptionValue\:\:banking_helper_tx_status_closed\(\) should return true but returns bool\.$#'
identifier: return.type
count: 1
path: CRM/Banking/Helpers/OptionValue.php
- -
- message: '#^Loose comparison via "\=\=" is not allowed\.$#'
- identifier: equal.notAllowed
- count: 2
- path: CRM/Banking/Helpers/OptionValue.php
-
-
message: '#^Only booleans are allowed in an if condition, int given\.$#'
identifier: if.condNotBoolean
@@ -1966,43 +1966,43 @@ parameters:
path: CRM/Banking/Helpers/Smarty.php
-
- message: '#^Function banking_helper_buildURL\(\) has parameter \$base with no type specified\.$#'
- identifier: missingType.parameter
+ message: '#^In method "CRM_Banking_Helpers_URLBuilder\:\:banking_helper_buildURL", you should not use the \$_REQUEST superglobal\. You should instead rely on your framework that provides you with a "request" object \(for instance a PSR\-7 RequestInterface or a Symfony Request\)\. More info\: http\://bit\.ly/nosuperglobals$#'
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
-
- message: '#^Function banking_helper_buildURL\(\) has parameter \$delete_params with no type specified\.$#'
- identifier: missingType.parameter
+ message: '#^Loose comparison via "\=\=" is not allowed\.$#'
+ identifier: equal.notAllowed
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
-
- message: '#^Function banking_helper_buildURL\(\) has parameter \$keep_param_source with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_URLBuilder\:\:banking_helper_buildURL\(\) has parameter \$base with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
-
- message: '#^Function banking_helper_buildURL\(\) has parameter \$keep_params with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_URLBuilder\:\:banking_helper_buildURL\(\) has parameter \$delete_params with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
-
- message: '#^Function banking_helper_buildURL\(\) has parameter \$set_params with no type specified\.$#'
+ message: '#^Method CRM_Banking_Helpers_URLBuilder\:\:banking_helper_buildURL\(\) has parameter \$keep_param_source with no type specified\.$#'
identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
-
- message: '#^In function "banking_helper_buildURL", you should not use the \$_REQUEST superglobal\. You should instead rely on your framework that provides you with a "request" object \(for instance a PSR\-7 RequestInterface or a Symfony Request\)\. More info\: http\://bit\.ly/nosuperglobals$#'
+ message: '#^Method CRM_Banking_Helpers_URLBuilder\:\:banking_helper_buildURL\(\) has parameter \$keep_params with no type specified\.$#'
+ identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
-
- message: '#^Loose comparison via "\=\=" is not allowed\.$#'
- identifier: equal.notAllowed
+ message: '#^Method CRM_Banking_Helpers_URLBuilder\:\:banking_helper_buildURL\(\) has parameter \$set_params with no type specified\.$#'
+ identifier: missingType.parameter
count: 1
path: CRM/Banking/Helpers/URLBuilder.php
@@ -6225,6 +6225,12 @@ parameters:
count: 1
path: CRM/Banking/PluginImpl/Matcher/CreateCampaignContribution.php
+ -
+ message: '#^Parameter \#2 \$array of function implode expects array\, array\ given\.$#'
+ identifier: argument.type
+ count: 1
+ path: CRM/Banking/PluginImpl/Matcher/CreateCampaignContribution.php
+
-
message: '#^Parameter \#2 \$btx \(CRM_Banking_BAO_BankTransaction\) of method CRM_Banking_PluginImpl_Matcher_CreateCampaignContribution\:\:execute\(\) should be contravariant with parameter \$btx \(mixed\) of method CRM_Banking_PluginModel_Matcher\:\:execute\(\)$#'
identifier: method.childParameterType
@@ -6846,12 +6852,6 @@ parameters:
count: 1
path: CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
- -
- message: '#^Variable property access on mixed\.$#'
- identifier: property.dynamicName
- count: 1
- path: CRM/Banking/PluginImpl/Matcher/ExistingContribution.php
-
-
message: '#^Access to an undefined property object\:\:\$dont_ignore\.$#'
identifier: property.notFound
@@ -8133,12 +8133,6 @@ parameters:
count: 2
path: CRM/Banking/PluginImpl/Matcher/RulesAnalyser.php
- -
- message: '#^Variable property access on mixed\.$#'
- identifier: property.dynamicName
- count: 2
- path: CRM/Banking/PluginImpl/Matcher/RulesAnalyser.php
-
-
message: '#^Access to an undefined property object\:\:\$contribution_status_id\.$#'
identifier: property.notFound
@@ -8429,7 +8423,7 @@ parameters:
-
message: '#^Parameter \#2 \$timestamp of function date expects int\|null, int\|false given\.$#'
identifier: argument.type
- count: 2
+ count: 1
path: CRM/Banking/PluginImpl/Matcher/SepaMandate.php
-
@@ -8447,7 +8441,7 @@ parameters:
-
message: '#^Variable property access on mixed\.$#'
identifier: property.dynamicName
- count: 3
+ count: 2
path: CRM/Banking/PluginImpl/Matcher/SepaMandate.php
-
@@ -9388,6 +9382,12 @@ parameters:
count: 6
path: CRM/Banking/PluginImpl/PostProcessor/MembershipPayment.php
+ -
+ message: '#^Parameter \#2 \$array of function implode expects array\, array\ given\.$#'
+ identifier: argument.type
+ count: 1
+ path: CRM/Banking/PluginImpl/PostProcessor/MembershipPayment.php
+
-
message: '#^Access to an undefined property object\:\:\$name\.$#'
identifier: property.notFound
@@ -11582,7 +11582,7 @@ parameters:
-
message: '#^Variable property access on \$this\(CRM_Banking_Rules_Rule\)\.$#'
identifier: property.dynamicName
- count: 14
+ count: 9
path: CRM/Banking/Rules/Rule.php
-
diff --git a/tests/phpunit/CRM/Banking/Analyser/RulesAnalyserTest.php b/tests/phpunit/CRM/Banking/Analyser/RulesAnalyserTest.php
index bf0b1616..c0c12948 100644
--- a/tests/phpunit/CRM/Banking/Analyser/RulesAnalyserTest.php
+++ b/tests/phpunit/CRM/Banking/Analyser/RulesAnalyserTest.php
@@ -33,7 +33,7 @@ class CRM_Banking_Analyser_RulesAnalyserTest extends CRM_Banking_TestBase {
*/
public function testRulesAnalyserBasic():void {
// get status IDs
- $payment_states = banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
+ $payment_states = CRM_Banking_Helpers_OptionValue::banking_helper_optiongroup_id_name_mapping('civicrm_banking.bank_tx_status');
$state_processed = (int) $payment_states['processed']['id'];
// create a transaction to process
diff --git a/tests/phpunit/CRM/Banking/TestBase.php b/tests/phpunit/CRM/Banking/TestBase.php
index 830b1b13..219277d8 100644
--- a/tests/phpunit/CRM/Banking/TestBase.php
+++ b/tests/phpunit/CRM/Banking/TestBase.php
@@ -573,7 +573,7 @@ public function getAllTransactionIDs($status_ids = NULL) {
public function getTxStatusID($status) {
static $status_list = [];
if (!isset($status_list[$status])) {
- $status_entry = banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', $status);
+ $status_entry = CRM_Banking_Helpers_OptionValue::banking_helper_optionvalueid_by_groupname_and_name('civicrm_banking.bank_tx_status', $status);
$status_list[$status] = $status_entry;
}
return $status_list[$status];