AssetInventoryItemList.php in farmOS 2.x
File
modules/core/inventory/src/Field/AssetInventoryItemList.php
View source
<?php
namespace Drupal\farm_inventory\Field;
use Drupal\Core\Field\FieldItemList;
use Drupal\Core\TypedData\ComputedItemListTrait;
class AssetInventoryItemList extends FieldItemList {
use ComputedItemListTrait;
protected function computeValue() {
$entity = $this
->getEntity();
$inventories = \Drupal::service('asset.inventory')
->getInventory($entity);
foreach ($inventories as $delta => $inventory) {
$this->list[$delta] = $this
->createItem($delta, $inventory);
}
}
}