Skip to content

Commit c7340ee

Browse files
author
Oleksii Korshenko
authored
MAGETWO-67351: remove duplicate calls to initObjectManager in bootstrap class #9140
2 parents a9bd85b + 7e8213b commit c7340ee

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

lib/internal/Magento/Framework/App/Bootstrap.php

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public function __construct(ObjectManagerFactory $factory, $rootDir, array $init
204204
$this->factory = $factory;
205205
$this->rootDir = $rootDir;
206206
$this->server = $initParams;
207+
$this->objectManager = $this->factory->create($this->server);
207208
}
208209

209210
/**
@@ -227,7 +228,6 @@ public function getParams()
227228
public function createApplication($type, $arguments = [])
228229
{
229230
try {
230-
$this->initObjectManager();
231231
$application = $this->objectManager->create($type, $arguments);
232232
if (!($application instanceof AppInterface)) {
233233
throw new \InvalidArgumentException("The provided class doesn't implement AppInterface: {$type}");
@@ -250,7 +250,6 @@ public function run(AppInterface $application)
250250
try {
251251
\Magento\Framework\Profiler::start('magento');
252252
$this->initErrorHandler();
253-
$this->initObjectManager();
254253
$this->assertMaintenance();
255254
$this->assertInstalled();
256255
$response = $application->launch();
@@ -279,7 +278,6 @@ protected function assertMaintenance()
279278
if (null === $isExpected) {
280279
return;
281280
}
282-
$this->initObjectManager();
283281
/** @var \Magento\Framework\App\MaintenanceMode $maintenance */
284282
$this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class);
285283

@@ -312,7 +310,6 @@ protected function assertInstalled()
312310
if (null === $isExpected) {
313311
return;
314312
}
315-
$this->initObjectManager();
316313
$isInstalled = $this->isInstalled();
317314
if (!$isInstalled && $isExpected) {
318315
$this->errorCode = self::ERR_IS_INSTALLED;
@@ -351,7 +348,6 @@ private function getIsExpected($key, $default)
351348
*/
352349
private function isInstalled()
353350
{
354-
$this->initObjectManager();
355351
/** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */
356352
$deploymentConfig = $this->objectManager->get(\Magento\Framework\App\DeploymentConfig::class);
357353
return $deploymentConfig->isAvailable();
@@ -364,7 +360,6 @@ private function isInstalled()
364360
*/
365361
public function getObjectManager()
366362
{
367-
$this->initObjectManager();
368363
return $this->objectManager;
369364
}
370365

@@ -378,20 +373,7 @@ private function initErrorHandler()
378373
$handler = new ErrorHandler();
379374
set_error_handler([$handler, 'handler']);
380375
}
381-
382-
/**
383-
* Initializes object manager
384-
*
385-
* @return void
386-
*/
387-
private function initObjectManager()
388-
{
389-
if (!$this->objectManager) {
390-
$this->objectManager = $this->factory->create($this->server);
391-
$this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class);
392-
}
393-
}
394-
376+
395377
/**
396378
* Getter for error code
397379
*

0 commit comments

Comments
 (0)