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
7 
11 class Proxy extends \Magento\Framework\Translate\Inline implements
13 {
19  protected $objectManager;
20 
26  protected $instanceName;
27 
33  protected $subject;
34 
40  protected $isShared;
41 
47  public function __construct(
49  $instanceName = \Magento\Framework\Translate\Inline::class,
50  $shared = true
51  ) {
52  $this->objectManager = $objectManager;
53  $this->instanceName = $instanceName;
54  $this->isShared = $shared;
55  }
56 
60  public function __sleep()
61  {
62  return ['subject', 'isShared'];
63  }
64 
70  public function __wakeup()
71  {
73  }
74 
80  public function __clone()
81  {
82  $this->subject = clone $this->_getSubject();
83  }
84 
90  protected function _getSubject()
91  {
92  if (!$this->subject) {
93  $this->subject = true === $this->isShared
94  ? $this->objectManager->get($this->instanceName)
95  : $this->objectManager->create($this->instanceName);
96  }
97  return $this->subject;
98  }
99 
105  public function isAllowed()
106  {
107  return $this->_getSubject()->isAllowed();
108  }
109 
115  public function getParser()
116  {
117  return $this->_getSubject()->getParser();
118  }
119 
127  public function processResponseBody(&$body, $isJson = false)
128  {
129  return $this->_getSubject()->processResponseBody($body, $isJson);
130  }
131 
138  public function getAdditionalHtmlAttribute($tagName = null)
139  {
140  return $this->_getSubject()->getAdditionalHtmlAttribute($tagName);
141  }
142 }
processResponseBody(&$body, $isJson=false)
Definition: Proxy.php:127
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, $instanceName=\Magento\Framework\Translate\Inline::class, $shared=true)
Definition: Proxy.php:47