Move Log Owner base field to dedicated farm_owner module.
This commit is contained in:
parent
1f0c254e79
commit
0f84ff1575
|
@ -165,17 +165,6 @@ function farm_entity_log_base_fields() {
|
||||||
'view' => 0,
|
'view' => 0,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'owner' => [
|
|
||||||
'type' => 'entity_reference',
|
|
||||||
'label' => t('Assigned to'),
|
|
||||||
'description' => t('Optionally assign this task to one or more people.'),
|
|
||||||
'target_type' => 'user',
|
|
||||||
'multiple' => TRUE,
|
|
||||||
'weight' => [
|
|
||||||
'form' => -70,
|
|
||||||
'view' => -70,
|
|
||||||
],
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
$fields = [];
|
$fields = [];
|
||||||
foreach ($field_info as $name => $info) {
|
foreach ($field_info as $name => $info) {
|
||||||
|
|
|
@ -22,5 +22,6 @@ dependencies:
|
||||||
- farm:farm_location
|
- farm:farm_location
|
||||||
- farm:farm_log_category
|
- farm:farm_log_category
|
||||||
- farm:farm_log_quantity
|
- farm:farm_log_quantity
|
||||||
|
- farm:farm_owner
|
||||||
- log:log
|
- log:log
|
||||||
- token:token
|
- token:token
|
||||||
|
|
|
@ -36,6 +36,7 @@ class FarmEntityFieldTest extends KernelTestBase {
|
||||||
'farm_entity_test',
|
'farm_entity_test',
|
||||||
'farm_location',
|
'farm_location',
|
||||||
'farm_log',
|
'farm_log',
|
||||||
|
'farm_owner',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
name: farmOS Owner
|
||||||
|
description: Provides an Owner field for farmOS records.
|
||||||
|
type: module
|
||||||
|
package: farmOS
|
||||||
|
core_version_requirement: ^9
|
||||||
|
dependencies:
|
||||||
|
- drupal:user
|
||||||
|
- farm:farm_field
|
||||||
|
- log:log
|
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file
|
||||||
|
* Contains farm_owner.module.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Drupal\Core\Entity\EntityTypeInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_entity_base_field_info().
|
||||||
|
*/
|
||||||
|
function farm_owner_entity_base_field_info(EntityTypeInterface $entity_type) {
|
||||||
|
$fields = [];
|
||||||
|
|
||||||
|
// Add owner field to logs.
|
||||||
|
if ($entity_type->id() == 'log') {
|
||||||
|
$field_info = [
|
||||||
|
'type' => 'entity_reference',
|
||||||
|
'label' => t('Assigned to'),
|
||||||
|
'description' => t('Optionally assign this task to one or more people.'),
|
||||||
|
'target_type' => 'user',
|
||||||
|
'multiple' => TRUE,
|
||||||
|
'weight' => [
|
||||||
|
'form' => -70,
|
||||||
|
'view' => -70,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
$fields['owner'] = \Drupal::service('farm_field.factory')->baseFieldDefinition($field_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $fields;
|
||||||
|
}
|
Loading…
Reference in New Issue