Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
RendererProxy.php
Go to the documentation of this file.
1 <?php
7 
12 {
18  protected $_objectManager = null;
19 
25  protected $_instanceName = null;
26 
32  protected $_subject = null;
33 
39  protected $_isShared = null;
40 
48  public function __construct(
50  $instanceName = \Magento\Framework\DB\Select\SelectRenderer::class,
51  $shared = true
52  ) {
53  $this->_objectManager = $objectManager;
54  $this->_instanceName = $instanceName;
55  $this->_isShared = $shared;
56  }
57 
61  public function __sleep()
62  {
63  return ['_subject', '_isShared'];
64  }
65 
71  public function __wakeup()
72  {
73  $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
74  }
75 
81  public function __clone()
82  {
83  $this->_subject = clone $this->_getSubject();
84  }
85 
91  protected function _getSubject()
92  {
93  if (!$this->_subject) {
94  $this->_subject = true === $this->_isShared
95  ? $this->_objectManager->get($this->_instanceName)
96  : $this->_objectManager->create($this->_instanceName);
97  }
98  return $this->_subject;
99  }
100 
104  public function render(\Magento\Framework\DB\Select $select, $sql = '')
105  {
106  return $this->_getSubject()->render($select, $sql);
107  }
108 }
$objectManager
Definition: bootstrap.php:17
render(\Magento\Framework\DB\Select $select, $sql='')
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName=\Magento\Framework\DB\Select\SelectRenderer::class, $shared=true)