diff options
author | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
---|---|---|
committer | Yaco <franco@reevo.org> | 2020-06-04 11:01:00 -0300 |
commit | fc7369835258467bf97eb64f184b93691f9a9fd5 (patch) | |
tree | daabd60089d2dd76d9f5fb416b005fbe159c799d /www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/Civi/Api4/Generic/DAOUpdateAction.php |
first commit
Diffstat (limited to 'www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/Civi/Api4/Generic/DAOUpdateAction.php')
-rw-r--r-- | www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/Civi/Api4/Generic/DAOUpdateAction.php | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/Civi/Api4/Generic/DAOUpdateAction.php b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/Civi/Api4/Generic/DAOUpdateAction.php new file mode 100644 index 00000000..62da8796 --- /dev/null +++ b/www/crm/wp-content/plugins/civicrm/civicrm/ext/api4/Civi/Api4/Generic/DAOUpdateAction.php @@ -0,0 +1,31 @@ +<?php + +namespace Civi\Api4\Generic; + +use Civi\Api4\Generic\Result; + +/** + * Update one or more records with new values. + * + * Use the where clause (required) to select them. + */ +class DAOUpdateAction extends AbstractUpdateAction { + use Traits\DAOActionTrait; + + /** + * @inheritDoc + */ + public function _run(Result $result) { + if (!empty($this->values['id'])) { + throw new \Exception("Cannot update the id of an existing " . $this->getEntityName() . '.'); + } + + $items = $this->getObjects(); + foreach ($items as &$item) { + $item = $this->values + $item; + } + + $result->exchangeArray($this->writeObjects($items)); + } + +} |