Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
HandlerPool.php
Go to the documentation of this file.
1 <?php
7 
10 
16 {
20  protected $objectManager;
21 
25  protected $defaultHandler;
26 
31  public function __construct(
34  ) {
35  $this->defaultHandler = $defaultHandler;
36  $this->objectManager = $objectManager;
37  }
38 
46  public function get($handlerClass = null)
47  {
48  if ($handlerClass === null) {
49  return $this->defaultHandler;
50  }
51 
52  $handler = $this->objectManager->get($handlerClass);
53  if (!$handler instanceof HandlerInterface) {
54  throw new \InvalidArgumentException(
55  $handlerClass . ' doesn\'t implement \Magento\Framework\Indexer\HandlerInterface'
56  );
57  }
58 
59  return $handler;
60  }
61 }
__construct(ObjectManagerInterface $objectManager, DefaultHandler $defaultHandler)
Definition: HandlerPool.php:31
catch(\Exception $e) $handler
Definition: index.php:30