4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
20 namespace Civi\Api4\Generic
;
23 * Base class for all batch actions (Update, Delete, Replace).
25 * This differs from the AbstractQuery class in that the "Where" clause is required.
27 * @package Civi\Api4\Generic
29 abstract class AbstractBatchAction
extends AbstractQueryAction
{
32 * Criteria for selecting $ENTITIES to process.
37 protected $where = [];
45 * BatchAction constructor.
46 * @param string $entityName
47 * @param string $actionName
48 * @param string|array $select
49 * One or more fields to load for each item.
51 public function __construct($entityName, $actionName, $select = 'id') {
52 $this->select
= (array) $select;
53 parent
::__construct($entityName, $actionName);
57 * Get a list of records for this batch.
61 protected function getBatchRecords() {
62 return (array) $this->getBatchAction()->execute();
66 * Get a query which resolves the list of records for this batch.
68 * This is similar to `getBatchRecords()`, but you may further refine the
69 * API call (e.g. selecting different fields or data-pages) before executing.
71 * @return \Civi\Api4\Generic\AbstractGetAction
73 protected function getBatchAction() {
75 'checkPermissions' => $this->checkPermissions
,
76 'where' => $this->where
,
77 'orderBy' => $this->orderBy
,
78 'limit' => $this->limit
,
79 'offset' => $this->offset
,
81 if (empty($this->reload
)) {
82 $params['select'] = $this->select
;
84 return \Civi\API\Request
::create($this->getEntityName(), 'get', ['version' => 4] +
$params);
90 protected function getSelect() {