Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QueryResolver.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Quote\Model;
7 
12 
14 {
18  private $data = [];
19 
23  private $config;
24 
28  private $cache;
29 
33  private $cacheId;
34 
40  private $cacheTags = [];
41 
45  private $serializer;
46 
53  public function __construct(
54  ConfigInterface $config,
55  CacheInterface $cache,
56  $cacheId = 'connection_config_cache',
57  SerializerInterface $serializer = null
58  ) {
59  $this->config = $config;
60  $this->cache = $cache;
61  $this->cacheId = $cacheId;
62  $this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
63  }
64 
70  public function isSingleQuery()
71  {
72  if (!isset($this->data['checkout'])) {
73  $this->initData();
74  }
75  return $this->data['checkout'];
76  }
77 
82  protected function initData()
83  {
84  $data = $this->cache->load($this->cacheId);
85  if (false === $data) {
86  $singleQuery = $this->config->getConnectionName('checkout_setup') == 'default' ? true : false;
87  $data['checkout'] = $singleQuery;
88  $this->cache->save($this->serializer->serialize($data), $this->cacheId, $this->cacheTags);
89  } else {
90  $data = $this->serializer->unserialize($data);
91  }
92  $this->merge($data);
93  }
94 
101  public function merge(array $config)
102  {
103  $this->data = array_replace_recursive($this->data, $config);
104  }
105 }
$config
Definition: fraud_order.php:17
__construct(ConfigInterface $config, CacheInterface $cache, $cacheId='connection_config_cache', SerializerInterface $serializer=null)