/**
* Massage values into the format the BAO expects for a write operation
*
- * @param $params
- * @param $entity
- * @param $fields
+ * @param array $params
+ * @param array $fields
* @throws \API_Exception
*/
- public static function formatWriteParams(&$params, $entity, $fields) {
+ public static function formatWriteParams(&$params, $fields) {
foreach ($fields as $name => $field) {
if (!empty($params[$name])) {
$value =& $params[$name];
if ($value === 'null') {
$value = 'Null';
}
- self::formatInputValue($value, $name, $field, $entity);
+ self::formatInputValue($value, $name, $field);
// Ensure we have an array for serialized fields
if (!empty($field['serialize'] && !is_array($value))) {
$value = (array) $value;
* @param $value
* @param string $fieldName
* @param array $fieldSpec
- * @param string $entity
- * Ex: 'Contact', 'Domain'
* @throws \API_Exception
*/
- public static function formatInputValue(&$value, $fieldName, $fieldSpec, $entity) {
+ public static function formatInputValue(&$value, $fieldName, $fieldSpec) {
// Evaluate pseudoconstant suffix
$suffix = strpos($fieldName, ':');
if ($suffix) {
$options = self::getPseudoconstantList($fieldSpec['entity'], $fieldSpec['name'], substr($fieldName, $suffix + 1));
$value = self::replacePseudoconstant($options, $value, TRUE);
+ return;
}
elseif (is_array($value)) {
foreach ($value as &$val) {
- self::formatInputValue($val, $fieldName, $fieldSpec, $entity);
+ self::formatInputValue($val, $fieldName, $fieldSpec);
}
return;
}
- $fk = $fieldSpec['name'] == 'id' ? $entity : $fieldSpec['fk_entity'] ?? NULL;
+ $fk = $fieldSpec['name'] == 'id' ? $fieldSpec['entity'] : $fieldSpec['fk_entity'] ?? NULL;
if ($fk === 'Domain' && $value === 'current_domain') {
$value = \CRM_Core_Config::domainID();