Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ValueHandlerPool.php
Go to the documentation of this file.
1 <?php
7 
10 
21 {
25  const DEFAULT_HANDLER = 'default';
26 
30  private $handlers;
31 
36  public function __construct(
37  TMapFactory $tmapFactory,
38  array $handlers
39  ) {
40  if (!isset($handlers[self::DEFAULT_HANDLER])) {
41  throw new \LogicException('Default handler should be provided.');
42  }
43 
44  $this->handlers = $tmapFactory->create(
45  [
46  'array' => $handlers,
47  'type' => ValueHandlerInterface::class
48  ]
49  );
50  }
51 
58  public function get($field)
59  {
60  return isset($this->handlers[$field])
61  ? $this->handlers[$field]
62  : $this->handlers[self::DEFAULT_HANDLER];
63  }
64 }
__construct(TMapFactory $tmapFactory, array $handlers)