diff --git a/farm.profile b/farm.profile index 701633f8..ee7b435a 100644 --- a/farm.profile +++ b/farm.profile @@ -50,6 +50,7 @@ function farm_modules() { 'farm_group' => t('Group assets'), 'farm_transplanting' => t('Transplanting logs'), 'farm_lab_test' => t('Lab test logs'), + 'farm_birth' => t('Birth logs'), 'farm_medical' => t('Medical logs'), 'farm_purchase' => t('Purchase logs'), 'farm_sale' => t('Sale logs'), diff --git a/modules/core/migrate/config/optional/migrate_plus.migration.farm_migrate_log_birth.yml b/modules/core/migrate/config/optional/migrate_plus.migration.farm_migrate_log_birth.yml new file mode 100644 index 00000000..e68fbcc3 --- /dev/null +++ b/modules/core/migrate/config/optional/migrate_plus.migration.farm_migrate_log_birth.yml @@ -0,0 +1,42 @@ +langcode: en +status: true +dependencies: + enforced: + module: + - farm_birth + - farm_migrate +id: farm_migrate_log_birth +label: 'Logs (Birth)' +migration_group: farm_migrate_log +migration_tags: + - 'Drupal 7' + - 'farmOS 1.x' +class: Drupal\migrate\Plugin\Migration +field_plugin_method: null +cck_plugin_method: null +source: + plugin: d7_farm_log + bundle: farm_birth +destination: + plugin: 'entity:log' +process: + # Hard-code the bundle. + type: + plugin: default_value + default_value: birth + # Maintain the log ID. + id: + plugin: get + source: id + # Birth specific fields. + mother: + plugin: sub_process + source: field_farm_mother + process: + target_id: + plugin: farm_migration_group_lookup + migration_group: farm_migrate_asset + source: target_id +migration_dependencies: + required: { } + optional: { } diff --git a/modules/log/birth/config/install/log.type.birth.yml b/modules/log/birth/config/install/log.type.birth.yml new file mode 100644 index 00000000..e12a9cf5 --- /dev/null +++ b/modules/log/birth/config/install/log.type.birth.yml @@ -0,0 +1,12 @@ +langcode: en +status: true +dependencies: + enforced: + module: + - farm_birth +id: birth +label: Birth +description: '' +name_pattern: 'Birth log [log:id]' +workflow: log_default +new_revision: true diff --git a/modules/log/birth/farm_birth.info.yml b/modules/log/birth/farm_birth.info.yml new file mode 100644 index 00000000..9eea4822 --- /dev/null +++ b/modules/log/birth/farm_birth.info.yml @@ -0,0 +1,8 @@ +name: Birth log +description: Adds a Birth log type for Animal assets. +type: module +package: farmOS Logs +core_version_requirement: ^9 +dependencies: + - farm:farm_animal + - farm:farm_entity diff --git a/modules/log/birth/src/Plugin/Log/LogType/Birth.php b/modules/log/birth/src/Plugin/Log/LogType/Birth.php new file mode 100644 index 00000000..ee3f1b44 --- /dev/null +++ b/modules/log/birth/src/Plugin/Log/LogType/Birth.php @@ -0,0 +1,51 @@ + 'entity_reference', + 'label' => $this->t('Mother'), + 'target_type' => 'asset', + 'target_bundle' => 'animal', + 'weight' => [ + 'form' => 55, + 'view' => -5, + ], + ]; + $fields['mother'] = $this->farmFieldFactory->bundleFieldDefinition($options); + + // Veterinarian. + $options = [ + 'type' => 'string', + 'label' => $this->t('Veterinarian'), + 'description' => $this->t('If a veterinarian was involved, enter their name here.'), + 'weight' => [ + 'form' => -40, + 'view' => -40, + ], + ]; + $fields['vet'] = $this->farmFieldFactory->bundleFieldDefinition($options); + + return $fields; + } + +}