Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Collection.php
Go to the documentation of this file.
1 <?php
8 
10 
17 class Collection implements \Iterator
18 {
22  protected $pool;
23 
27  protected $saleableItem;
28 
32  protected $priceFactory;
33 
37  protected $quantity;
38 
42  protected $contains;
43 
47  protected $excludes;
48 
54  protected $priceModels;
55 
64  public function __construct(
67  Pool $pool,
68  $quantity
69  ) {
70  $this->saleableItem = $saleableItem;
71  $this->priceFactory = $priceFactory;
72  $this->pool = $pool;
73  $this->quantity = $quantity;
74  $this->priceModels = [];
75  }
76 
82  public function rewind()
83  {
84  return $this->pool->rewind();
85  }
86 
92  public function current()
93  {
94  return $this->get($this->key());
95  }
96 
102  public function key()
103  {
104  return $this->pool->key();
105  }
106 
112  public function next()
113  {
114  return $this->pool->next();
115  }
116 
122  public function valid()
123  {
124  return $this->pool->valid();
125  }
126 
133  public function get($code)
134  {
135  if (!isset($this->priceModels[$code])) {
136  $this->priceModels[$code] = $this->priceFactory->create(
137  $this->saleableItem,
138  $this->pool[$code],
139  $this->quantity
140  );
141  }
142  return $this->priceModels[$code];
143  }
144 }
__construct(SaleableInterface $saleableItem, Factory $priceFactory, Pool $pool, $quantity)
Definition: Collection.php:64
$code
Definition: info.phtml:12