Merge pull request #20601 from kartik1000/pcpshortcode
[civicrm-core.git] / Civi / Api4 / Generic / DAOSaveAction.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 +--------------------------------------------------------------------+
11 */
12
13 namespace Civi\Api4\Generic;
14
15 /**
16 * @inheritDoc
17 */
18 class 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;
27 $this->formatWriteValues($record);
28 if (empty($record['id'])) {
29 $this->fillDefaults($record);
30 }
31 }
32 $this->validateValues();
33
34 $resultArray = $this->writeObjects($this->records);
35
36 $result->exchangeArray($resultArray);
37 }
38
39 }