forked from civicrm/org.civicrm.api4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractBatchAction.php
64 lines (55 loc) · 1.32 KB
/
AbstractBatchAction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Civi\Api4\Generic;
/**
* Base class for all batch actions (Update, Delete, Replace).
*
* This differs from the AbstractQuery class in that the "Where" clause is required.
*
* @package Civi\Api4\Generic
*/
abstract class AbstractBatchAction extends AbstractQueryAction {
/**
* Criteria for selecting items to process.
*
* @required
* @var array
*/
protected $where = [];
/**
* @var array
*/
private $select;
/**
* BatchAction constructor.
* @param string $entityName
* @param string $actionName
* @param string|array $select
* One or more fields to load for each item.
*/
public function __construct($entityName, $actionName, $select = 'id') {
$this->select = (array) $select;
parent::__construct($entityName, $actionName);
}
/**
* @return array
*/
protected function getBatchRecords() {
$params = [
'checkPermissions' => $this->checkPermissions,
'where' => $this->where,
'orderBy' => $this->orderBy,
'limit' => $this->limit,
'offset' => $this->offset,
];
if (empty($this->reload)) {
$params['select'] = $this->select;
}
return (array) civicrm_api4($this->getEntityName(), 'get', $params);
}
/**
* @return array
*/
protected function getSelect() {
return $this->select;
}
}