api4 - Import CRM/, Civi/, templates/, ang/, css/, js/, xml/menu
[civicrm-core.git] / Civi / Api4 / Generic / AbstractUpdateAction.php
1 <?php
2
3 namespace Civi\Api4\Generic;
4
5 /**
6 * Base class for all "Update" api actions
7 *
8 * @method $this setValues(array $values) Set all field values from an array of key => value pairs.
9 * @method $this addValue($field, $value) Set field value.
10 * @method array getValues() Get field values.
11 * @method $this setReload(bool $reload) Specify whether complete objects will be returned after saving.
12 * @method bool getReload()
13 *
14 * @package Civi\Api4\Generic
15 */
16 abstract class AbstractUpdateAction extends AbstractBatchAction {
17
18 /**
19 * Field values to update.
20 *
21 * @var array
22 * @required
23 */
24 protected $values = [];
25
26 /**
27 * Reload objects after saving.
28 *
29 * Setting to TRUE will load complete records and return them as the api result.
30 * If FALSE the api usually returns only the fields specified to be updated.
31 *
32 * @var bool
33 */
34 protected $reload = FALSE;
35
36 /**
37 * @param string $key
38 *
39 * @return mixed|null
40 */
41 public function getValue($key) {
42 return isset($this->values[$key]) ? $this->values[$key] : NULL;
43 }
44
45 }