Commit | Line | Data |
---|---|---|
a646bdd2 SB |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
fee14197 | 4 | | CiviCRM version 5 | |
a646bdd2 | 5 | +--------------------------------------------------------------------+ |
f299f7db | 6 | | Copyright CiviCRM LLC (c) 2004-2020 | |
a646bdd2 SB |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
ca5cec67 | 31 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
a646bdd2 SB |
32 | */ |
33 | class CRM_Batch_BAO_EntityBatch extends CRM_Batch_DAO_EntityBatch { | |
34 | ||
ee20d7be PN |
35 | /** |
36 | * Create entity batch entry. | |
37 | * | |
38 | * @param array $params | |
39 | * @return array | |
40 | */ | |
41 | public static function create(&$params) { | |
42 | $op = 'edit'; | |
43 | $entityId = CRM_Utils_Array::value('id', $params); | |
44 | if (!$entityId) { | |
45 | $op = 'create'; | |
46 | } | |
47 | CRM_Utils_Hook::pre($op, 'EntityBatch', $entityId, $params); | |
48 | $entityBatch = new CRM_Batch_DAO_EntityBatch(); | |
49 | $entityBatch->copyValues($params); | |
50 | $entityBatch->save(); | |
51 | CRM_Utils_Hook::post($op, 'EntityBatch', $entityBatch->id, $entityBatch); | |
52 | return $entityBatch; | |
53 | } | |
54 | ||
55 | /** | |
56 | * Remove entries from entity batch. | |
e989fc66 | 57 | * @param array|int $params |
ee20d7be PN |
58 | * @return CRM_Batch_DAO_EntityBatch |
59 | */ | |
60 | public static function del($params) { | |
e989fc66 | 61 | if (!is_array($params)) { |
be2fb01f | 62 | $params = ['id' => $params]; |
e989fc66 | 63 | } |
ee20d7be PN |
64 | $entityBatch = new CRM_Batch_DAO_EntityBatch(); |
65 | $entityId = CRM_Utils_Array::value('id', $params); | |
66 | CRM_Utils_Hook::pre('delete', 'EntityBatch', $entityId, $params); | |
67 | $entityBatch->copyValues($params); | |
68 | $entityBatch->delete(); | |
69 | CRM_Utils_Hook::post('delete', 'EntityBatch', $entityBatch->id, $entityBatch); | |
70 | return $entityBatch; | |
71 | } | |
72 | ||
a646bdd2 | 73 | } |