Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AppliersPool.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  private $appliersPool = [];
17 
22  public function __construct(array $appliers)
23  {
24  $this->appliersPool = $appliers;
25  $this->checkAppliers();
26  }
27 
33  private function checkAppliers()
34  {
35  foreach ($this->appliersPool as $applier) {
36  if (!($applier instanceof ApplierInterface)) {
37  throw new \InvalidArgumentException('Report filter applier must implement ApplierInterface');
38  }
39  }
40  return true;
41  }
42 
48  public function getApplier($filter)
49  {
50  if (is_object($filter)) {
51  $filterClass = get_class($filter);
52  if (array_key_exists($filterClass, $this->appliersPool)) {
53  return $this->appliersPool[$filterClass];
54  }
55  }
56  return null;
57  }
58 }