forked from farmOS/farmOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add asset inventory views field farmOS#679
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
modules/core/inventory/config/schema/farm_inventory.views.schema.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Schema for the asset inventory views field handler. | ||
views.field.asset_inventory: | ||
type: views.field.field | ||
label: 'Asset inventory field handler' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Provides Views data for farm_inventory.module. | ||
*/ | ||
|
||
/** | ||
* Implements hook_views_data_alter(). | ||
*/ | ||
function farm_inventory_views_data_alter(array &$data) { | ||
|
||
// Add computed inventory field to assets. | ||
if (isset($data['asset'])) { | ||
$data['asset']['inventory'] = [ | ||
'title' => t('Current inventory'), | ||
'field' => [ | ||
'id' => 'asset_inventory', | ||
'field_name' => 'inventory', | ||
], | ||
]; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
modules/core/inventory/src/Plugin/views/field/AssetInventory.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace Drupal\farm_inventory\Plugin\views\field; | ||
|
||
use Drupal\views\Plugin\views\field\EntityField; | ||
|
||
/** | ||
* A field that displays asset inventory. | ||
* | ||
* @ingroup views_field_handlers | ||
* | ||
* @ViewsField("asset_inventory") | ||
*/ | ||
class AssetInventory extends EntityField { | ||
|
||
} |