WishlistPurchaseItemList.php in Commerce Wishlist 8.3
File
src/Plugin/Field/FieldType/WishlistPurchaseItemList.php
View source
<?php
namespace Drupal\commerce_wishlist\Plugin\Field\FieldType;
use Drupal\commerce_wishlist\WishlistPurchase;
use Drupal\Core\Field\FieldItemList;
class WishlistPurchaseItemList extends FieldItemList implements WishlistPurchaseItemListInterface {
public function getPurchases() {
$purchases = [];
foreach ($this->list as $key => $field_item) {
if (!$field_item
->isEmpty()) {
$purchases[$key] = $field_item
->toPurchase();
}
}
return $purchases;
}
public function removePurchase(WishlistPurchase $purchase) {
foreach ($this->list as $key => $field_item) {
if ($purchase == $field_item
->toPurchase()) {
$this
->removeItem($key);
}
}
}
}