Merge pull request #18281 from sunilpawar/report_48
[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 /**
14 *
15 * @package CRM
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
17 */
18
19
20 namespace Civi\Api4\Generic;
21
22 /**
23 * @inheritDoc
24 */
25 class DAOSaveAction extends AbstractSaveAction {
26 use Traits\DAOActionTrait;
27
28 /**
29 * @inheritDoc
30 */
31 public function _run(Result $result) {
32 foreach ($this->records as &$record) {
33 $record += $this->defaults;
34 $this->formatWriteValues($record);
35 if (empty($record['id'])) {
36 $this->fillDefaults($record);
37 }
38 }
39 $this->validateValues();
40
41 $resultArray = $this->writeObjects($this->records);
42
43 $result->exchangeArray($resultArray);
44 }
45
46 }