Commit 571c91af authored by mattwire's avatar mattwire
Browse files

Handle deprecated API4 joins

parent 8b1dabd9
......@@ -25,7 +25,7 @@ class PaymentprocessorWebhook extends Generic\DAOEntity {
public static function get($checkPermissions = TRUE) {
return (new DAOGetAction(static::class, __FUNCTION__))
->setCheckPermissions($checkPermissions)
->addWhere('payment_processor.domain_id', '=', \CRM_Core_Config::domainID());
->addWhere(self::getJoinFKAlias() . '.domain_id', '=', \CRM_Core_Config::domainID());
}
/**
......@@ -35,7 +35,7 @@ class PaymentprocessorWebhook extends Generic\DAOEntity {
public static function update($checkPermissions = TRUE) {
return (new DAOUpdateAction(static::class, __FUNCTION__))
->setCheckPermissions($checkPermissions)
->addWhere('payment_processor.domain_id', '=', \CRM_Core_Config::domainID());
->addWhere(self::getJoinFKAlias() . '.domain_id', '=', \CRM_Core_Config::domainID());
}
/**
......@@ -45,7 +45,7 @@ class PaymentprocessorWebhook extends Generic\DAOEntity {
public static function delete($checkPermissions = TRUE) {
return (new DAODeleteAction(static::class, __FUNCTION__))
->setCheckPermissions($checkPermissions)
->addWhere('payment_processor.domain_id', '=', \CRM_Core_Config::domainID());
->addWhere(self::getJoinFKAlias() . '.domain_id', '=', \CRM_Core_Config::domainID());
}
/**
......@@ -55,6 +55,20 @@ class PaymentprocessorWebhook extends Generic\DAOEntity {
public static function replace($checkPermissions = TRUE) {
return (new BasicReplaceAction(static::class, __FUNCTION__))
->setCheckPermissions($checkPermissions)
->addWhere('payment_processor.domain_id', '=', \CRM_Core_Config::domainID());
->addWhere(self::getJoinFKAlias() . '.domain_id', '=', \CRM_Core_Config::domainID());
}
/**
* API4 changed autoJoinFK format in 5.38
* See https://github.com/civicrm/civicrm-core/pull/20130
*
* @return string
* @throws \CRM_Core_Exception
*/
private static function getJoinFKAlias(): string {
if (version_compare(\CRM_Utils_System::version(), '5.38', '<')) {
return 'payment_processor';
}
return 'payment_processor_id';
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment