alterPaymentProcessorParams hook and propertyBag
See https://github.com/civicrm/civicrm-core/pull/17507#issuecomment-690213686:
pass property bag to alterPaymentProcessorParams
✔ the hook gets to deal with sensible, known data and does not have to (re-)implement all the quirks of checking different array keys for one thing.✔ any setting the hook does in a prop bag ensures forward consistency for the next process in the chain (another hook or the main process)✖ It's possible that the reason for a hook is something pretty darn weird needs doing; in which case the raw array may be more useful.pass the original array to the hook
✖ hook has to do all work arounds✖ hook is free to implement bad practise in altering the array✔ hook can do whatever it likes.I think (1).
And example from Stripe where we're currently passing an array for compatibility (but this should not be used as a model as Stripe ignores the return values from the hook anyway). https://lab.civicrm.org/extensions/stripe/-/blob/master/CRM/Core/Payment/Stripe.php#L484-489
// @fixme DO NOT SET ANYTHING ON $propertyBag or $params BELOW THIS LINE (we are reading from both)
$params = $this->getPropertyBagAsArray($propertyBag);
// We don't actually use this hook with Stripe, but useful to trigger so listeners can see raw params
$newParams = [];
CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $newParams);