/**
  * Returns object manager factory
  *
  * @param array $arguments
  * @return FactoryDecorator | FactoryCompiled
  */
 public function getObjectManagerFactory($arguments)
 {
     $factoryClass = $this->getDiConfig()->getPreference($this->configPreference);
     $this->factory = new $factoryClass($this->getDiConfig(), null, $this->envFactory->getDefinitions(), $arguments);
     if (isset($arguments['MAGE_PROFILER']) && $arguments['MAGE_PROFILER'] == 2) {
         $this->factory = new FactoryDecorator($this->factory, \Magento\Framework\ObjectManager\Profiler\Log::getInstance());
     }
     return $this->factory;
 }
 /**
  * Decorate factory
  *
  * @param array $arguments
  * @return void
  */
 protected function decorate($arguments)
 {
     if (isset($arguments['MAGE_PROFILER']) && $arguments['MAGE_PROFILER'] == 2) {
         $this->factory = new FactoryDecorator($this->factory, Log::getInstance());
     }
 }
 /**
  * Create ObjectManager
  *
  * @param string $rootDir
  * @param array $arguments
  * @param bool $useCompiled
  * @return \Magento\Framework\ObjectManager
  *
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function create($rootDir, array $arguments, $useCompiled = true)
 {
     $directories = isset($arguments[Filesystem::PARAM_APP_DIRS]) ? $arguments[Filesystem::PARAM_APP_DIRS] : array();
     $directoryList = new DirectoryList($rootDir, $directories);
     (new \Magento\Framework\Autoload\IncludePath())->addIncludePath(array($directoryList->getDir(Filesystem::GENERATION_DIR)));
     $appArguments = $this->createAppArguments($directoryList, $arguments);
     $definitionFactory = new \Magento\Framework\ObjectManager\DefinitionFactory(new \Magento\Framework\Filesystem\Driver\File(), $directoryList->getDir(Filesystem::DI_DIR), $directoryList->getDir(Filesystem::GENERATION_DIR), $appArguments->get('definition.format', 'serialized'));
     $definitions = $definitionFactory->createClassDefinition($appArguments->get('definitions'), $useCompiled);
     $relations = $definitionFactory->createRelations();
     $configClass = $this->_configClassName;
     /** @var \Magento\Framework\ObjectManager\Config\Config $diConfig */
     $diConfig = new $configClass($relations, $definitions);
     $appMode = $appArguments->get(State::PARAM_MODE, State::MODE_DEFAULT);
     $booleanUtils = new \Magento\Framework\Stdlib\BooleanUtils();
     $argInterpreter = $this->createArgumentInterpreter($booleanUtils);
     $argumentMapper = new \Magento\Framework\ObjectManager\Config\Mapper\Dom($argInterpreter);
     $configData = $this->_loadPrimaryConfig($directoryList, $argumentMapper, $appMode);
     if ($configData) {
         $diConfig->extend($configData);
     }
     $this->factory = new \Magento\Framework\ObjectManager\Factory\Factory($diConfig, null, $definitions, $appArguments->get());
     if ($appArguments->get('MAGE_PROFILER') == 2) {
         $this->factory = new \Magento\Framework\ObjectManager\Profiler\FactoryDecorator($this->factory, \Magento\Framework\ObjectManager\Profiler\Log::getInstance());
     }
     $className = $this->_locatorClassName;
     $sharedInstances = ['Magento\\Framework\\App\\Arguments' => $appArguments, 'Magento\\Framework\\App\\Filesystem\\DirectoryList' => $directoryList, 'Magento\\Framework\\Filesystem\\DirectoryList' => $directoryList, 'Magento\\Framework\\ObjectManager\\Relations' => $relations, 'Magento\\Framework\\Interception\\Definition' => $definitionFactory->createPluginDefinition(), 'Magento\\Framework\\ObjectManager\\Config' => $diConfig, 'Magento\\Framework\\ObjectManager\\Definition' => $definitions, 'Magento\\Framework\\Stdlib\\BooleanUtils' => $booleanUtils, 'Magento\\Framework\\ObjectManager\\Config\\Mapper\\Dom' => $argumentMapper, $configClass => $diConfig];
     /** @var \Magento\Framework\ObjectManager $objectManager */
     $objectManager = new $className($this->factory, $diConfig, $sharedInstances);
     $this->factory->setObjectManager($objectManager);
     ObjectManager::setInstance($objectManager);
     /** @var \Magento\Framework\App\Filesystem\DirectoryList\Verification $verification */
     $verification = $objectManager->get('Magento\\Framework\\App\\Filesystem\\DirectoryList\\Verification');
     $verification->createAndVerifyDirectories();
     $diConfig->setCache($objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigCache'));
     $objectManager->configure($objectManager->get('Magento\\Framework\\App\\ObjectManager\\ConfigLoader')->load('global'));
     $objectManager->get('Magento\\Framework\\Config\\ScopeInterface')->setCurrentScope('global');
     $objectManager->get('Magento\\Framework\\App\\Resource')->setCache($objectManager->get('Magento\\Framework\\App\\CacheInterface'));
     $interceptionConfig = $objectManager->get('Magento\\Framework\\Interception\\Config\\Config');
     $diConfig->setInterceptionConfig($interceptionConfig);
     $this->configureDirectories($objectManager);
     return $objectManager;
 }