Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Protected Attributes
HandlerPool Class Reference

Public Member Functions

 __construct (ObjectManagerInterface $objectManager, DefaultHandler $defaultHandler)
 
 get ($handlerClass=null)
 

Protected Attributes

 $objectManager
 
 $defaultHandler
 

Detailed Description

@api Instantiate save handler when implementing custom Indexer\Action

Since
100.0.2

Definition at line 15 of file HandlerPool.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( ObjectManagerInterface  $objectManager,
DefaultHandler  $defaultHandler 
)
Parameters
ObjectManagerInterface$objectManager
DefaultHandler$defaultHandler

Definition at line 31 of file HandlerPool.php.

34  {
35  $this->defaultHandler = $defaultHandler;
36  $this->objectManager = $objectManager;
37  }

Member Function Documentation

◆ get()

get (   $handlerClass = null)

Get handler class instance

Parameters
string$handlerClass
Exceptions

Definition at line 46 of file HandlerPool.php.

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  }
catch(\Exception $e) $handler
Definition: index.php:30

Field Documentation

◆ $defaultHandler

$defaultHandler
protected

Definition at line 25 of file HandlerPool.php.

◆ $objectManager

$objectManager
protected

Definition at line 20 of file HandlerPool.php.


The documentation for this class was generated from the following file: