/** * @param \Magento\Framework\Config\ReaderInterface $reader * @param \Magento\Framework\Config\ScopeListInterface $scopeList * @param \Magento\Framework\Cache\FrontendInterface $cache * @param \Magento\Framework\ObjectManager\RelationsInterface $relations * @param \Magento\Framework\Interception\ObjectManager\ConfigInterface $omConfig * @param \Magento\Framework\ObjectManager\DefinitionInterface $classDefinitions * @param string $cacheId */ public function __construct(\Magento\Framework\Config\ReaderInterface $reader, \Magento\Framework\Config\ScopeListInterface $scopeList, \Magento\Framework\Cache\FrontendInterface $cache, \Magento\Framework\ObjectManager\RelationsInterface $relations, \Magento\Framework\Interception\ObjectManager\ConfigInterface $omConfig, \Magento\Framework\ObjectManager\DefinitionInterface $classDefinitions, $cacheId = 'interception') { $this->_omConfig = $omConfig; $this->_relations = $relations; $this->_classDefinitions = $classDefinitions; $this->_cache = $cache; $this->_cacheId = $cacheId; $this->_reader = $reader; $this->_scopeList = $scopeList; $intercepted = $this->_cache->load($this->_cacheId); if ($intercepted !== false) { $this->_intercepted = unserialize($intercepted); } else { $this->initialize($this->_classDefinitions->getClasses()); } }
/** * Extend configuration * * @param array $configuration * @return void */ public function extend(array $configuration) { if ($this->_cache) { if (!$this->_currentCacheKey) { $this->_currentCacheKey = md5(serialize([$this->_arguments, $this->_nonShared, $this->_preferences, $this->_virtualTypes])); } $key = md5($this->_currentCacheKey . serialize($configuration)); $cached = $this->_cache->get($key); if ($cached) { list($this->_arguments, $this->_nonShared, $this->_preferences, $this->_virtualTypes, $this->_mergedArguments) = $cached; } else { $this->_mergeConfiguration($configuration); if (!$this->_mergedArguments) { foreach ($this->_definitions->getClasses() as $class) { $this->_collectConfiguration($class); } } $this->_cache->save([$this->_arguments, $this->_nonShared, $this->_preferences, $this->_virtualTypes, $this->_mergedArguments], $key); } $this->_currentCacheKey = $key; } else { $this->_mergeConfiguration($configuration); } }
/** * Returns class definitions * * @return array */ protected function getClassDefinitions() { return $this->_classDefinitions->getClasses(); }