3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
12 namespace Civi\Api4\Generic\Traits
;
14 use Civi\Api4\Generic\BasicBatchAction
;
15 use Civi\Api4\Generic\ExportAction
;
18 * A managed entity includes extra fields and methods to revert from an overridden local to base state.
20 * Includes the extra fields `has_base` and `base_module`
25 * @param bool $checkPermissions
26 * @return \Civi\Api4\Generic\BasicBatchAction
28 public static function revert($checkPermissions = TRUE) {
29 return (new BasicBatchAction(static::getEntityName(), __FUNCTION__
, function($item, BasicBatchAction
$action) {
30 $params = ['entity_type' => $action->getEntityName(), 'entity_id' => $item['id']];
31 if (\CRM_Core_ManagedEntities
::singleton()->revert($params)) {
35 throw new \
API_Exception('Cannot revert ' . $action->getEntityName() . ' with id ' . $item['id']);
37 }))->setCheckPermissions($checkPermissions);
41 * @param bool $checkPermissions
42 * @return \Civi\Api4\Generic\ExportAction
44 public static function export($checkPermissions = TRUE) {
45 return (new ExportAction(static::getEntityName(), __FUNCTION__
))
46 ->setCheckPermissions($checkPermissions);