Merge pull request #23342 from eileenmcnaughton/import_map
[civicrm-core.git] / Civi / Api4 / Generic / DAOSaveAction.php
CommitLineData
19b53e5b
C
1<?php
2
380f3545
TO
3/*
4 +--------------------------------------------------------------------+
41498ac5 5 | Copyright CiviCRM LLC. All rights reserved. |
380f3545 6 | |
41498ac5
TO
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 |
380f3545
TO
10 +--------------------------------------------------------------------+
11 */
12
19b53e5b
C
13namespace Civi\Api4\Generic;
14
15/**
58efbb45 16 * @inheritDoc
19b53e5b
C
17 */
18class DAOSaveAction extends AbstractSaveAction {
19 use Traits\DAOActionTrait;
20
21 /**
22 * @inheritDoc
23 */
24 public function _run(Result $result) {
25 foreach ($this->records as &$record) {
26 $record += $this->defaults;
961e974c 27 $this->formatWriteValues($record);
db11224f 28 $this->matchExisting($record);
19b53e5b
C
29 if (empty($record['id'])) {
30 $this->fillDefaults($record);
31 }
32 }
33 $this->validateValues();
34
35 $resultArray = $this->writeObjects($this->records);
36
37 $result->exchangeArray($resultArray);
38 }
39
40}