From 7ee75dd7f32af8ab75f0e7422f18f3d1742e3e11 Mon Sep 17 00:00:00 2001 From: matze Date: Tue, 10 Dec 2024 16:17:32 +0100 Subject: [PATCH] added work log NEXT: add substance log --- src/Plugin/Log/LogType/FieldWork.php | 2 +- src/Plugin/Log/LogType/WorkLog.php | 36 ++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/Plugin/Log/LogType/WorkLog.php diff --git a/src/Plugin/Log/LogType/FieldWork.php b/src/Plugin/Log/LogType/FieldWork.php index e065d02..4a6bcd0 100644 --- a/src/Plugin/Log/LogType/FieldWork.php +++ b/src/Plugin/Log/LogType/FieldWork.php @@ -12,7 +12,7 @@ use Drupal\farm_entity\Plugin\Log\LogType\FarmLogType; * label = @Translation("Field work"), * ) */ -class FieldWork extends FarmLogType { +class FieldWork extends WorkLog { /** * {@inheritdoc} */ diff --git a/src/Plugin/Log/LogType/WorkLog.php b/src/Plugin/Log/LogType/WorkLog.php new file mode 100644 index 0000000..08d7432 --- /dev/null +++ b/src/Plugin/Log/LogType/WorkLog.php @@ -0,0 +1,36 @@ + [ + 'type' => 'entity_reference', + 'label' => $this->t('Work'), + 'description' => $this->t("What type of work was done?"), + 'target_type' => 'taxonomy_term', + 'target_bundle' => 'work', + 'auto_create' => FALSE, + 'required' => TRUE, + 'multiple' => FALSE, + ], + ]; + + foreach ($field_info as $name => $info) { + $fields[$name] = \Drupal::service('farm_field.factory')->bundleFieldDefinition($info); + } + + return $fields; + } +}