}
catch (InvalidArgumentException $e) {
- CRM_Core_Error::deprecatedFunctionWarning(
- "proper getCustomProperty('$offset') for non-core properties. "
- . $e->getMessage(),
- "PropertyBag array access to get '$offset'"
- );
+ if (!$this->getSuppressLegacyWarnings()) {
+ CRM_Core_Error::deprecatedFunctionWarning(
+ "proper getCustomProperty('$offset') for non-core properties. "
+ . $e->getMessage(),
+ "PropertyBag array access to get '$offset'"
+ );
+ }
try {
return $this->getCustomProperty($offset, 'default');
}
}
- CRM_Core_Error::deprecatedFunctionWarning(
- "get" . ucfirst($offset) . "()",
- "PropertyBag array access for core property '$offset'"
- );
+ if (!$this->getSuppressLegacyWarnings()) {
+ CRM_Core_Error::deprecatedFunctionWarning(
+ "get" . ucfirst($offset) . "()",
+ "PropertyBag array access for core property '$offset'"
+ );
+ }
return $this->get($prop, 'default');
}
throw new \InvalidArgumentException("Unknown property '$prop'.");
}
// Remaining case is legacy name that's been translated.
- if (!$this->suppressLegacyWarnings) {
+ if (!$this->getSuppressLegacyWarnings()) {
CRM_Core_Error::deprecatedFunctionWarning("Canonical property name '$newName'", "Legacy property name '$prop'");
}
*
* @return PropertyBag $this object so you can chain set setters.
*/
- protected function set($prop, $label = 'default', $value) {
+ protected function set($prop, $label, $value) {
$this->props[$label][$prop] = $value;
return $this;
}
// Suppress legacy warnings for merging an array of data as this
// suits our migration plan at this moment. Future behaviour may differ.
// @see https://github.com/civicrm/civicrm-core/pull/17643
- $this->suppressLegacyWarnings = TRUE;
+ $suppressLegacyWarnings = $this->getSuppressLegacyWarnings();
+ $this->setSuppressLegacyWarnings(TRUE);
foreach ($data as $key => $value) {
if ($value !== NULL && $value !== '') {
$this->offsetSet($key, $value);
}
}
- $this->suppressLegacyWarnings = FALSE;
+ $this->setSuppressLegacyWarnings($suppressLegacyWarnings);
}
/**
*/
public function setRecurInstallments($recurInstallments, $label = 'default') {
// Counts zero as positive which is ok - means no installments
- if (!\CRM_Utils_Type::validate($recurInstallments, 'Positive')) {
+ try {
+ \CRM_Utils_Type::validate($recurInstallments, 'Positive');
+ }
+ catch (\CRM_Core_Exception $e) {
throw new InvalidArgumentException('recurInstallments must be 0 or a positive integer');
}