Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SaveHandlerFactory.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  const PHP_NATIVE_HANDLER = \Magento\Framework\Session\SaveHandler\Native::class;
17 
23  protected $objectManager;
24 
30  protected $handlers = [];
31 
38  public function __construct(\Magento\Framework\ObjectManagerInterface $objectManger, array $handlers = [])
39  {
40  $this->objectManager = $objectManger;
41  if (!empty($handlers)) {
42  $this->handlers = array_merge($handlers, $this->handlers);
43  }
44  }
45 
54  public function create($saveMethod, $params = [])
55  {
56  $sessionHandler = self::PHP_NATIVE_HANDLER;
57  if (isset($this->handlers[$saveMethod])) {
58  $sessionHandler = $this->handlers[$saveMethod];
59  }
60 
61  $model = $this->objectManager->create($sessionHandler, $params);
62  if (!$model instanceof \SessionHandlerInterface) {
63  throw new \LogicException($sessionHandler . ' doesn\'t implement \SessionHandlerInterface');
64  }
65 
66  return $model;
67  }
68 }
$params[\Magento\Store\Model\StoreManager::PARAM_RUN_CODE]
Definition: website.php:18
__construct(\Magento\Framework\ObjectManagerInterface $objectManger, array $handlers=[])