protected function AssetInventoryItemList::computeValue in farmOS 2.x
Computes the current inventory value for the asset.
Overrides ComputedItemListTrait::computeValue
File
- modules/
core/ inventory/ src/ Field/ AssetInventoryItemList.php, line 18
Class
- AssetInventoryItemList
- Computes the current inventory value for assets.
Namespace
Drupal\farm_inventory\FieldCode
protected function computeValue() {
// Get the asset entity.
$entity = $this
->getEntity();
// Get the asset's current inventories.
$inventories = \Drupal::service('asset.inventory')
->getInventory($entity);
// Update the assets current inventory values to match.
// @todo Cache this field computation.
foreach ($inventories as $delta => $inventory) {
$this->list[$delta] = $this
->createItem($delta, $inventory);
}
}