Afform - Switch to APIv4 for managed afform_type option group
authorColeman Watts <coleman@civicrm.org>
Tue, 28 Jun 2022 15:59:45 +0000 (11:59 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 21 Jul 2022 21:22:27 +0000 (17:22 -0400)
ext/afform/core/managed/AfformType.mgd.php

index 2c0e8eb22890608ad72d14fb0a6b984b918683d0..5922d3b65faec93287138c9b30078a7c10e50d55 100644 (file)
 <?php
-// Adds option group for Afform.type
 
-$mgd = [
+use CRM_Afform_ExtensionUtil as E;
+
+// Adds option group for Afform.type
+return [
   [
     'name' => 'AfformType',
     'entity' => 'OptionGroup',
     'update' => 'always',
     'cleanup' => 'always',
     'params' => [
-      'name' => 'afform_type',
-      'title' => 'Afform Type',
-      'option_value_fields' => ['name', 'label', 'icon', 'description'],
+      'version' => 4,
+      'values' => [
+        'name' => 'afform_type',
+        'title' => E::ts('Afform Type'),
+        'description' => NULL,
+        'data_type' => NULL,
+        'is_reserved' => TRUE,
+        'is_active' => TRUE,
+        'is_locked' => FALSE,
+        'option_value_fields' => [
+          'name',
+          'label',
+          'icon',
+          'description',
+        ],
+      ],
+      'match' => ['name'],
     ],
   ],
   [
     'name' => 'AfformType:form',
     'entity' => 'OptionValue',
+    'cleanup' => 'always',
+    'update' => 'always',
     'params' => [
-      'option_group_id' => 'afform_type',
-      'name' => 'form',
-      'value' => 'form',
-      'label' => 'Submission Form',
-      'weight' => 0,
-      'icon' => 'fa-list-alt',
+      'version' => 4,
+      'values' => [
+        'option_group_id.name' => 'afform_type',
+        'name' => 'form',
+        'value' => 'form',
+        'label' => E::ts('Submission Form'),
+        'grouping' => NULL,
+        'filter' => 0,
+        'is_default' => FALSE,
+        'description' => NULL,
+        'is_optgroup' => FALSE,
+        'is_reserved' => FALSE,
+        'is_active' => TRUE,
+        'component_id' => NULL,
+        'domain_id' => NULL,
+        'visibility_id' => NULL,
+        'icon' => 'fa-list-alt',
+        'color' => NULL,
+      ],
+      'match' => ['option_group_id', 'name'],
     ],
   ],
   [
     'name' => 'AfformType:search',
     'entity' => 'OptionValue',
+    'cleanup' => 'always',
+    'update' => 'always',
     'params' => [
-      'option_group_id' => 'afform_type',
-      'name' => 'search',
-      'value' => 'search',
-      'label' => 'Search Form',
-      'weight' => 10,
-      'icon' => 'fa-search',
+      'version' => 4,
+      'values' => [
+        'option_group_id.name' => 'afform_type',
+        'name' => 'search',
+        'value' => 'search',
+        'label' => E::ts('Search Form'),
+        'grouping' => NULL,
+        'filter' => 0,
+        'is_default' => FALSE,
+        'description' => NULL,
+        'is_optgroup' => FALSE,
+        'is_reserved' => FALSE,
+        'is_active' => TRUE,
+        'component_id' => NULL,
+        'domain_id' => NULL,
+        'visibility_id' => NULL,
+        'icon' => 'fa-search',
+        'color' => NULL,
+      ],
+      'match' => ['option_group_id', 'name'],
     ],
   ],
   [
     'name' => 'AfformType:block',
     'entity' => 'OptionValue',
+    'cleanup' => 'always',
+    'update' => 'always',
     'params' => [
-      'option_group_id' => 'afform_type',
-      'name' => 'block',
-      'value' => 'block',
-      'label' => 'Field Block',
-      'weight' => 20,
-      'icon' => 'fa-th-large',
+      'version' => 4,
+      'values' => [
+        'option_group_id.name' => 'afform_type',
+        'name' => 'block',
+        'value' => 'block',
+        'label' => E::ts('Field Block'),
+        'grouping' => NULL,
+        'filter' => 0,
+        'is_default' => FALSE,
+        'description' => NULL,
+        'is_optgroup' => FALSE,
+        'is_reserved' => FALSE,
+        'is_active' => TRUE,
+        'component_id' => NULL,
+        'domain_id' => NULL,
+        'visibility_id' => NULL,
+        'icon' => 'fa-th-large',
+        'color' => NULL,
+      ],
+      'match' => ['option_group_id', 'name'],
     ],
   ],
   [
     'name' => 'AfformType:system',
     'entity' => 'OptionValue',
+    'cleanup' => 'always',
+    'update' => 'always',
     'params' => [
-      'option_group_id' => 'afform_type',
-      'name' => 'system',
-      'value' => 'system',
-      'label' => 'System Form',
-      'weight' => 50,
-      'icon' => 'fa-lock',
+      'version' => 4,
+      'values' => [
+        'option_group_id.name' => 'afform_type',
+        'name' => 'system',
+        'value' => 'system',
+        'label' => E::ts('System Form'),
+        'grouping' => NULL,
+        'filter' => 0,
+        'is_default' => FALSE,
+        'description' => NULL,
+        'is_optgroup' => FALSE,
+        'is_reserved' => FALSE,
+        'is_active' => TRUE,
+        'component_id' => NULL,
+        'domain_id' => NULL,
+        'visibility_id' => NULL,
+        'icon' => 'fa-lock',
+        'color' => NULL,
+      ],
+      'match' => ['option_group_id', 'name'],
     ],
   ],
 ];
-
-return $mgd;