Commit | Line | Data |
---|---|---|
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 | ||
13 | /** | |
14 | * | |
15 | * @package CRM | |
ca5cec67 | 16 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
380f3545 TO |
17 | * $Id$ |
18 | * | |
19 | */ | |
20 | ||
21 | ||
19b53e5b C |
22 | namespace Civi\Api4\Generic; |
23 | ||
24 | /** | |
25 | * Base class for all "Update" api actions | |
26 | * | |
27 | * @method $this setValues(array $values) Set all field values from an array of key => value pairs. | |
28 | * @method $this addValue($field, $value) Set field value. | |
29 | * @method array getValues() Get field values. | |
30 | * @method $this setReload(bool $reload) Specify whether complete objects will be returned after saving. | |
31 | * @method bool getReload() | |
32 | * | |
33 | * @package Civi\Api4\Generic | |
34 | */ | |
35 | abstract class AbstractUpdateAction extends AbstractBatchAction { | |
36 | ||
37 | /** | |
38 | * Field values to update. | |
39 | * | |
40 | * @var array | |
41 | * @required | |
42 | */ | |
43 | protected $values = []; | |
44 | ||
45 | /** | |
46 | * Reload objects after saving. | |
47 | * | |
48 | * Setting to TRUE will load complete records and return them as the api result. | |
49 | * If FALSE the api usually returns only the fields specified to be updated. | |
50 | * | |
51 | * @var bool | |
52 | */ | |
53 | protected $reload = FALSE; | |
54 | ||
55 | /** | |
56 | * @param string $key | |
57 | * | |
58 | * @return mixed|null | |
59 | */ | |
60 | public function getValue($key) { | |
61 | return isset($this->values[$key]) ? $this->values[$key] : NULL; | |
62 | } | |
63 | ||
64 | } |