AdjustmentItemList.php in Commerce Core 8.2
File
modules/order/src/Plugin/Field/FieldType/AdjustmentItemList.php
View source
<?php
namespace Drupal\commerce_order\Plugin\Field\FieldType;
use Drupal\commerce_order\Adjustment;
use Drupal\Core\Field\FieldItemList;
class AdjustmentItemList extends FieldItemList implements AdjustmentItemListInterface {
public function getAdjustments() {
$adjustments = [];
foreach ($this->list as $key => $field_item) {
if (!$field_item
->isEmpty()) {
$adjustments[$key] = $field_item->value;
}
}
return $adjustments;
}
public function removeAdjustment(Adjustment $adjustment) {
foreach ($this->list as $key => $field_item) {
if ($field_item->value === $adjustment) {
$this
->removeItem($key);
}
}
}
}