4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace Civi\Api4\Generic
;
23 * Create or update one or more $ENTITIES.
25 * If creating more than one $ENTITY with similar values, use the `defaults` param.
27 * Set `reload` if you need the api to return complete records for each saved $ENTITY.
29 class DAOSaveAction
extends AbstractSaveAction
{
30 use Traits\DAOActionTrait
;
35 public function _run(Result
$result) {
36 foreach ($this->records
as &$record) {
37 $record +
= $this->defaults
;
38 $this->formatWriteValues($record);
39 if (empty($record['id'])) {
40 $this->fillDefaults($record);
43 $this->validateValues();
45 $resultArray = $this->writeObjects($this->records
);
47 $result->exchangeArray($resultArray);