Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
IntervalFactory.php
Go to the documentation of this file.
1 <?php
7 
10 
16 {
20  private $interval;
21 
25  private $objectManager;
26 
32  public function __construct(
33  ObjectManagerInterface $objectManager,
34  EngineResolverInterface $engineResolver,
35  $intervals
36  ) {
37  $this->objectManager = $objectManager;
38  $configValue = $engineResolver->getCurrentSearchEngine();
39  if (isset($intervals[$configValue])) {
40  $this->interval = $intervals[$configValue];
41  } else {
42  throw new \LogicException("Interval not found by config {$configValue}");
43  }
44  }
45 
52  public function create(array $data = [])
53  {
54  $interval = $this->objectManager->create($this->interval, $data);
55  if (!$interval instanceof IntervalInterface) {
56  throw new \LogicException(
57  'Interval not instance of interface ' . IntervalInterface::class
58  );
59  }
60  return $interval;
61  }
62 }
__construct(ObjectManagerInterface $objectManager, EngineResolverInterface $engineResolver, $intervals)
$objectManager
Definition: bootstrap.php:17