mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Expose the computed "group" asset field to Views.
This commit is contained in:
parent
0eff167220
commit
58ced4cdb3
|
@ -29,6 +29,21 @@ function farm_group_entity_base_field_info(EntityTypeInterface $entity_type) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function farm_group_views_data_alter(array &$data) {
|
||||
|
||||
// Add the computed group membership field to assets.
|
||||
$data['asset']['group'] = [
|
||||
'title' => t('Current group'),
|
||||
'field' => [
|
||||
'id' => 'asset_group',
|
||||
'field_name' => 'group',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_pre_view().
|
||||
*/
|
||||
|
|
16
modules/asset/group/src/Plugin/views/field/AssetGroup.php
Normal file
16
modules/asset/group/src/Plugin/views/field/AssetGroup.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\farm_group\Plugin\views\field;
|
||||
|
||||
use Drupal\views\Plugin\views\field\EntityField;
|
||||
|
||||
/**
|
||||
* A field that displays asset group.
|
||||
*
|
||||
* @ingroup views_field_handlers
|
||||
*
|
||||
* @ViewsField("asset_group")
|
||||
*/
|
||||
class AssetGroup extends EntityField {
|
||||
|
||||
}
|
Loading…
Reference in a new issue