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 
13 class Proxy implements
16 {
22  protected $_objectManager = null;
23 
29  protected $_instanceName = null;
30 
36  protected $_subject = null;
37 
43  protected $_isShared = null;
44 
52  public function __construct(
54  $instanceName = \Magento\Framework\App\Route\ConfigInterface::class,
55  $shared = true
56  ) {
57  $this->_objectManager = $objectManager;
58  $this->_instanceName = $instanceName;
59  $this->_isShared = $shared;
60  }
61 
65  public function __sleep()
66  {
67  return ['_subject', '_isShared'];
68  }
69 
75  public function __wakeup()
76  {
77  $this->_objectManager = \Magento\Framework\App\ObjectManager::getInstance();
78  }
79 
85  public function __clone()
86  {
87  $this->_subject = clone $this->_getSubject();
88  }
89 
95  protected function _getSubject()
96  {
97  if (!$this->_subject) {
98  $this->_subject = true === $this->_isShared
99  ? $this->_objectManager->get($this->_instanceName)
100  : $this->_objectManager->create($this->_instanceName);
101  }
102  return $this->_subject;
103  }
104 
112  public function getRouteFrontName($routeId, $scope = null)
113  {
114  return $this->_getSubject()->getRouteFrontName($routeId, $scope);
115  }
116 
124  public function getRouteByFrontName($frontName, $scope = null)
125  {
126  return $this->_getSubject()->getRouteByFrontName($frontName, $scope);
127  }
128 
136  public function getModulesByFrontName($frontName, $scope = null)
137  {
138  $this->_getSubject()->getModulesByFrontName($frontName, $scope);
139  }
140 }
$objectManager
Definition: bootstrap.php:17
getModulesByFrontName($frontName, $scope=null)
Definition: Proxy.php:136
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName=\Magento\Framework\App\Route\ConfigInterface::class, $shared=true)
Definition: Proxy.php:52
getRouteByFrontName($frontName, $scope=null)
Definition: Proxy.php:124