Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Interval.php
Go to the documentation of this file.
1 <?php
7 
9 
13 class Interval implements IntervalInterface
14 {
18  private $resource;
19 
23  public function __construct(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price $resource)
24  {
25  $this->resource = $resource;
26  }
27 
31  public function load($limit, $offset = null, $lower = null, $upper = null)
32  {
33  $prices = $this->resource->loadPrices($limit, $offset, $lower, $upper);
34  return $this->arrayValuesToFloat($prices);
35  }
36 
40  public function loadPrevious($data, $index, $lower = null)
41  {
42  $prices = $this->resource->loadPreviousPrices($data, $index, $lower);
43  return $this->arrayValuesToFloat($prices);
44  }
45 
49  public function loadNext($data, $rightIndex, $upper = null)
50  {
51  $prices = $this->resource->loadNextPrices($data, $rightIndex, $upper);
52  return $this->arrayValuesToFloat($prices);
53  }
54 
61  private function arrayValuesToFloat($prices)
62  {
63  $returnPrices = [];
64  if (is_array($prices) && !empty($prices)) {
65  $returnPrices = array_map('floatval', $prices);
66  }
67  return $returnPrices;
68  }
69 }
__construct(\Magento\Catalog\Model\ResourceModel\Layer\Filter\Price $resource)
Definition: Interval.php:23
loadPrevious($data, $index, $lower=null)
Definition: Interval.php:40
$resource
Definition: bulk.php:12
$index
Definition: list.phtml:44
loadNext($data, $rightIndex, $upper=null)
Definition: Interval.php:49
load($limit, $offset=null, $lower=null, $upper=null)
Definition: Interval.php:31