added work log NEXT: add substance log

This commit is contained in:
2024-12-10 16:17:32 +01:00
parent cff83d30e9
commit 7ee75dd7f3
2 changed files with 37 additions and 1 deletions

View File

@@ -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}
*/

View File

@@ -0,0 +1,36 @@
<?php
namespace Drupal\farm_agrikern\Plugin\Log\LogType;
use Drupal\farm_entity\Plugin\Log\LogType\FarmLogType;
/**
* Provides the work log type.
*/
class WorkLog extends FarmLogType {
/**
* {@inheritdoc}
*/
public function buildFieldDefinitions() {
$fields = parent::buildFieldDefinitions();
$field_info = [
'work_field' => [
'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;
}
}