objectManager = $objectManager; $this->instanceName = $instanceName; $this->isShared = $shared; } /** * @return array */ public function __sleep() { return ['subject', 'isShared']; } /** * Retrieve ObjectManager from global scope * * @return void */ public function __wakeup() { $this->objectManager = \Magento\Framework\App\ObjectManager::getInstance(); } /** * Clone proxied instance * * @return void */ public function __clone() { $this->subject = clone $this->_getSubject(); } /** * Get proxied instance * * @return \Magento\Framework\Mview\Config\Data */ protected function _getSubject() { if (!$this->subject) { $this->subject = true === $this->isShared ? $this->objectManager->get( $this->instanceName ) : $this->objectManager->create( $this->instanceName ); } return $this->subject; } /** * {@inheritdoc} */ public function merge(array $config) { $this->_getSubject()->merge($config); } /** * {@inheritdoc} */ public function get($path = null, $default = null) { return $this->_getSubject()->get($path, $default); } }