From 2c218c5509195faa9401ac4948b3359adfc249c9 Mon Sep 17 00:00:00 2001 From: matze Date: Wed, 18 Dec 2024 01:31:24 +0100 Subject: [PATCH] write update function --- farm_agrikern.install | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 farm_agrikern.install diff --git a/farm_agrikern.install b/farm_agrikern.install new file mode 100644 index 0000000..1c8ad94 --- /dev/null +++ b/farm_agrikern.install @@ -0,0 +1,22 @@ +** +* Updates allowed taxonomy types. +*/ +function farm_agrikern_update_1(&$sandbox) { + // Updates field storage config for field_custom_radio_buttons. + // @see https://www.drupal.org/node/2012896 + // @see https://www.drupal.org/docs/8/api/update-api/updating-entities-and-fields-in-drupal-8#example-updating-a-field-from-an-obsolete-type-to-a-new-type + $old_config = FieldStorageConfig::loadByName('asset', 'crop_field'); + $new_config = $old_config->createDuplicate(); + $new_config->original = $new_config; + $new_config->enforceIsNew(FALSE); + $new_config + ->setSetting('target_bundle', 'plant_type') + ->save(); + $old_config = FieldStorageConfig::loadByName('log', 'work_field'); + $new_config = $old_config->createDuplicate(); + $new_config->original = $new_config; + $new_config->enforceIsNew(FALSE); + $new_config + ->setSetting('target_bundle', 'work_type') + ->save(); +} \ No newline at end of file