예제 #1
0
 /**
  * {inheritdoc}
  */
 public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstances)
 {
     $objectManager = ObjectManager::getInstance();
     $objectManager->configure($objectManager->get('Magento\\Framework\\ObjectManager\\ConfigLoaderInterface')->load(Area::AREA_GLOBAL));
     $objectManager->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope('global');
     $diConfig->setInterceptionConfig($objectManager->get('Magento\\Framework\\Interception\\Config\\Config'));
     $sharedInstances['Magento\\Framework\\Interception\\PluginList\\PluginList'] = $objectManager->create('Magento\\Framework\\Interception\\PluginListInterface', ['cache' => $objectManager->get('Magento\\Framework\\App\\Interception\\Cache\\CompiledConfig')]);
     $objectManager->get('Magento\\Framework\\App\\Cache\\Manager')->setEnabled([CompiledConfig::TYPE_IDENTIFIER], true);
 }
예제 #2
0
 /**
  * {inheritdoc}
  */
 public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstances)
 {
     $objectManager = ObjectManager::getInstance();
     $sharedInstances['Magento\\Framework\\ObjectManager\\ConfigLoaderInterface'] = $objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader');
     $diConfig->setCache($objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigCache'));
     $objectManager->configure($objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader')->load(Area::AREA_GLOBAL));
     $objectManager->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope('global');
     $diConfig->setInterceptionConfig($objectManager->get('Magento\\Framework\\Interception\\Config\\Config'));
 }
예제 #3
0
 /**
  * {inheritdoc}
  */
 public function configureObjectManager(ConfigInterface $diConfig, &$sharedInstances)
 {
     $originalSharedInstances = $sharedInstances;
     $objectManager = ObjectManager::getInstance();
     $sharedInstances['Magento\\Framework\\ObjectManager\\ConfigLoaderInterface'] = $objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader');
     $diConfig->setCache($objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigCache'));
     $objectManager->configure($objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader')->load(Area::AREA_GLOBAL));
     $objectManager->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope('global');
     $diConfig->setInterceptionConfig($objectManager->get('Magento\\Framework\\Interception\\Config\\Config'));
     /** Reset the shared instances once interception config is set so classes can be intercepted if necessary */
     $sharedInstances = $originalSharedInstances;
     $sharedInstances['Magento\\Framework\\ObjectManager\\ConfigLoaderInterface'] = $objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader');
 }
예제 #4
0
 /**
  * Process interception inheritance
  *
  * @param string $type
  * @return bool
  */
 protected function _inheritInterception($type)
 {
     $type = ltrim($type, '\\');
     if (!isset($this->_intercepted[$type])) {
         $realType = $this->_omConfig->getOriginalInstanceType($type);
         if ($type !== $realType) {
             if ($this->_inheritInterception($realType)) {
                 $this->_intercepted[$type] = true;
                 return true;
             }
         } else {
             $parts = explode('\\', $type);
             if (!in_array(end($parts), $this->_serviceClassTypes) && $this->_relations->has($type)) {
                 $relations = $this->_relations->getParents($type);
                 foreach ($relations as $relation) {
                     if ($relation && $this->_inheritInterception($relation)) {
                         $this->_intercepted[$type] = true;
                         return true;
                     }
                 }
             }
         }
         $this->_intercepted[$type] = false;
     }
     return $this->_intercepted[$type];
 }
예제 #5
0
 /**
  * Collect parent types configuration for requested type
  *
  * @param string $type
  * @return array
  * @throws \InvalidArgumentException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 protected function _inheritPlugins($type)
 {
     $type = ltrim($type, '\\');
     if (!array_key_exists($type, $this->_inherited)) {
         $realType = $this->_omConfig->getOriginalInstanceType($type);
         if ($realType !== $type) {
             $plugins = $this->_inheritPlugins($realType);
         } elseif ($this->_relations->has($type)) {
             $relations = $this->_relations->getParents($type);
             $plugins = [];
             foreach ($relations as $relation) {
                 if ($relation) {
                     $relationPlugins = $this->_inheritPlugins($relation);
                     if ($relationPlugins) {
                         $plugins = array_replace_recursive($plugins, $relationPlugins);
                     }
                 }
             }
         } else {
             $plugins = [];
         }
         if (isset($this->_data[$type])) {
             if (!$plugins) {
                 $plugins = $this->_data[$type];
             } else {
                 $plugins = array_replace_recursive($plugins, $this->_data[$type]);
             }
         }
         $this->_inherited[$type] = null;
         if (is_array($plugins) && count($plugins)) {
             uasort($plugins, [$this, '_sort']);
             $this->trimInstanceStartingBackslash($plugins);
             $this->_inherited[$type] = $plugins;
             $lastPerMethod = [];
             foreach ($plugins as $key => $plugin) {
                 // skip disabled plugins
                 if (isset($plugin['disabled']) && $plugin['disabled']) {
                     unset($plugins[$key]);
                     continue;
                 }
                 $pluginType = $this->_omConfig->getOriginalInstanceType($plugin['instance']);
                 if (!class_exists($pluginType)) {
                     throw new \InvalidArgumentException('Plugin class ' . $pluginType . ' doesn\'t exist');
                 }
                 foreach ($this->_definitions->getMethodList($pluginType) as $pluginMethod => $methodTypes) {
                     $current = isset($lastPerMethod[$pluginMethod]) ? $lastPerMethod[$pluginMethod] : '__self';
                     $currentKey = $type . '_' . $pluginMethod . '_' . $current;
                     if ($methodTypes & DefinitionInterface::LISTENER_AROUND) {
                         $this->_processed[$currentKey][DefinitionInterface::LISTENER_AROUND] = $key;
                         $lastPerMethod[$pluginMethod] = $key;
                     }
                     if ($methodTypes & DefinitionInterface::LISTENER_BEFORE) {
                         $this->_processed[$currentKey][DefinitionInterface::LISTENER_BEFORE][] = $key;
                     }
                     if ($methodTypes & DefinitionInterface::LISTENER_AFTER) {
                         $this->_processed[$currentKey][DefinitionInterface::LISTENER_AFTER][] = $key;
                     }
                 }
             }
         }
         return $plugins;
     }
     return $this->_inherited[$type];
 }