value pairs. * @method array getValues() Get field values. * * @package Civi\Api4\Generic */ abstract class AbstractCreateAction extends AbstractAction { /** * Field values to set for the new $ENTITY. * * @var array */ protected $values = []; /** * @param string $fieldName * @return mixed|null */ public function getValue(string $fieldName) { return $this->values[$fieldName] ?? NULL; } /** * Add a field value. * @param string $fieldName * @param mixed $value * @return $this */ public function addValue(string $fieldName, $value) { $this->values[$fieldName] = $value; return $this; } /** * @throws \API_Exception */ protected function validateValues() { $unmatched = $this->checkRequiredFields($this->getValues()); if ($unmatched) { throw new \API_Exception("Mandatory values missing from Api4 {$this->getEntityName()}::{$this->getActionName()}: " . implode(", ", $unmatched), "mandatory_missing", ["fields" => $unmatched]); } } }