Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Proxy.php
Go to the documentation of this file.
1 <?php
9 
10 class Proxy extends \Magento\Framework\App\AreaList implements
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\App\AreaList::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 
107  public function getCodeByFrontName($frontName)
108  {
109  return $this->_getSubject()->getCodeByFrontName($frontName);
110  }
111 
118  public function getFrontName($areaCode)
119  {
120  return $this->_getSubject()->getFrontName($areaCode);
121  }
122 
128  public function getCodes()
129  {
130  return $this->_getSubject()->getCodes();
131  }
132 
139  public function getDefaultRouter($areaCode)
140  {
141  return $this->_getSubject()->getDefaultRouter($areaCode);
142  }
143 
150  public function getArea($code)
151  {
152  return $this->_getSubject()->getArea($code);
153  }
154 }
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName=\Magento\Framework\App\AreaList::class, $shared=true)
Definition: Proxy.php:48
$code
Definition: info.phtml:12