Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AbstractEnvironment.php
Go to the documentation of this file.
1 <?php
8 
15 
16 abstract class AbstractEnvironment implements EnvironmentInterface
17 {
21  protected $config;
22 
26  protected $mode = 'developer';
27 
31  protected $configPreference = \Magento\Framework\ObjectManager\Factory\Dynamic\Developer::class;
32 
36  protected $factory;
37 
41  protected $envFactory;
42 
47  {
48  $this->envFactory = $envFactory;
49  }
50 
58  {
59  $factoryClass = $this->getDiConfig()->getPreference($this->configPreference);
60 
61  $this->factory = $this->createFactory($arguments, $factoryClass);
62  $this->decorate($arguments);
63 
64  return $this->factory;
65  }
66 
72  public function getMode()
73  {
74  return $this->mode;
75  }
76 
83  protected function decorate($arguments)
84  {
85  if (isset($arguments['MAGE_PROFILER']) && $arguments['MAGE_PROFILER'] == 2) {
86  $this->factory = new FactoryDecorator(
87  $this->factory,
89  );
90  }
91  }
92 
101  protected function createFactory($arguments, $factoryClass)
102  {
103  return new $factoryClass(
104  $this->getDiConfig(),
105  null,
106  $this->envFactory->getDefinitions(),
107  $arguments
108  );
109  }
110 }
$arguments