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 +--------------------------------------------------------------------+
13 namespace Civi\Api4\Generic
;
16 * Base class for all batch actions (Update, Delete, Replace).
18 * This differs from the AbstractQuery class in that the "Where" clause is required.
20 * @package Civi\Api4\Generic
22 abstract class AbstractBatchAction
extends AbstractQueryAction
{
25 * Criteria for selecting $ENTITIES to process.
30 protected $where = [];
38 * BatchAction constructor.
39 * @param string $entityName
40 * @param string $actionName
41 * @param string|array $select
42 * One or more fields to load for each item.
44 public function __construct($entityName, $actionName, $select = 'id') {
45 $this->select
= (array) $select;
46 parent
::__construct($entityName, $actionName);
50 * Get a list of records for this batch.
54 protected function getBatchRecords() {
55 return (array) $this->getBatchAction()->execute();
59 * Get a query which resolves the list of records for this batch.
61 * This is similar to `getBatchRecords()`, but you may further refine the
62 * API call (e.g. selecting different fields or data-pages) before executing.
64 * @return \Civi\Api4\Generic\AbstractGetAction
66 protected function getBatchAction() {
68 'checkPermissions' => $this->checkPermissions
,
69 'where' => $this->where
,
70 'orderBy' => $this->orderBy
,
71 'limit' => $this->limit
,
72 'offset' => $this->offset
,
74 if (empty($this->reload
)) {
75 $params['select'] = $this->select
;
77 return \Civi\API\Request
::create($this->getEntityName(), 'get', ['version' => 4] +
$params);
83 protected function getSelect() {