* (change the x in the function name):
*/
- // /**
- // * Upgrade function.
- // *
- // * @param string $rev
- // */
- // public function upgrade_5_0_x($rev) {
- // $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
- // $this->addTask('Do the foo change', 'taskFoo', ...);
- // // Additional tasks here...
- // // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
- // // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
- // }
-
- // public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
- // return TRUE;
- // }
+ /**
+ * Upgrade function.
+ *
+ * @param string $rev
+ */
+ public function upgrade_5_28_alpha1($rev) {
+ $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
+ $this->addTask('Add icon column to civicrm_custom_group', 'addColumn',
+ 'civicrm_custom_group', 'icon', "varchar(255) COMMENT 'crm-i icon class' DEFAULT NULL");
+ }
+ /**
+ * Upgrade function.
+ *
+ * @param string $rev
+ */
+ public function upgrade_5_28_alpha1($rev) {
+ $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
+ $this->addTask('Populate missing Contact Type name fields', 'populateMissingContactTypeName');
+ }
+
+ public static function populateMissingContactTypeName() {
+ $contactTypes = \Civi\Api4\ContactType::get()
+ ->setCheckPermissions(FALSE)
+ ->execute();
+ foreach ($contactTypes as $contactType) {
+ if (empty($contactType['name'])) {
+ \Civi\Api4\ContactType::update()
+ ->addWhere('id', '=', $contactType['id'])
+ ->addValue('name', ucfirst(CRM_Utils_String::munge($contactType['label'])))
+ ->setCheckPermissions(FALSE)
+ ->execute();
+ }
+ }
+ return TRUE;
+ }
+
}