X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=ext%2Fafform%2Fcore%2FCivi%2FApi4%2FAfform.php;h=15d2aea8d8f2a06943dfd033b4ef1ea4bf328a31;hb=6802fa7e788481d6119a4da5cfc3dbddd615ed96;hp=c1f481e20dad70e673eb908f5181ac743f395f4d;hpb=f50b23dc99a10614afc5fea21af88c53aee57139;p=civicrm-core.git diff --git a/ext/afform/core/Civi/Api4/Afform.php b/ext/afform/core/Civi/Api4/Afform.php index c1f481e20d..15d2aea8d8 100644 --- a/ext/afform/core/Civi/Api4/Afform.php +++ b/ext/afform/core/Civi/Api4/Afform.php @@ -2,7 +2,6 @@ namespace Civi\Api4; -use Civi\Api4\Generic\BasicBatchAction; use Civi\Api4\Generic\BasicGetFieldsAction; /** @@ -105,33 +104,11 @@ class Afform extends Generic\AbstractEntity { /** * @param bool $checkPermissions - * @return Generic\BasicBatchAction + * @return Action\Afform\Revert */ public static function revert($checkPermissions = TRUE) { - return (new BasicBatchAction('Afform', __FUNCTION__, function($item, BasicBatchAction $action) { - $scanner = \Civi::service('afform_scanner'); - $files = [ - \CRM_Afform_AfformScanner::METADATA_FILE, - \CRM_Afform_AfformScanner::LAYOUT_FILE, - ]; - - foreach ($files as $file) { - $metaPath = $scanner->createSiteLocalPath($item['name'], $file); - if (file_exists($metaPath)) { - if (!@unlink($metaPath)) { - throw new \API_Exception("Failed to remove afform overrides in $file"); - } - } - } - - // We may have changed list of files covered by the cache. - _afform_clear(); - - // FIXME if `server_route` changes, then flush the menu cache. - // FIXME if asset-caching is enabled, then flush the asset cache - - return $item; - }))->setCheckPermissions($checkPermissions); + return (new Action\Afform\Revert('Afform', __FUNCTION__)) + ->setCheckPermissions($checkPermissions); } /** @@ -188,6 +165,10 @@ class Afform extends Generic\AbstractEntity { 'tab' => ts('Contact Summary Tab'), ], ], + [ + 'name' => 'icon', + 'description' => 'Icon shown in the contact summary tab', + ], [ 'name' => 'server_route', ], @@ -259,8 +240,8 @@ class Afform extends Generic\AbstractEntity { */ public static function permissions() { return [ - "meta" => ["access CiviCRM"], - "default" => ["administer CiviCRM"], + 'meta' => ['access CiviCRM'], + 'default' => [['administer CiviCRM', 'administer afform']], // These all check form-level permissions 'get' => [], 'getOptions' => [],