Skip to content

Commit

Permalink
MAGETWO-67351: remove duplicate calls to initObjectManager in bootstr…
Browse files Browse the repository at this point in the history
…ap class #9140
  • Loading branch information
Oleksii Korshenko authored Apr 11, 2017
2 parents a9bd85b + 7e8213b commit c7340ee
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions lib/internal/Magento/Framework/App/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public function __construct(ObjectManagerFactory $factory, $rootDir, array $init
$this->factory = $factory;
$this->rootDir = $rootDir;
$this->server = $initParams;
$this->objectManager = $this->factory->create($this->server);
}

/**
Expand All @@ -227,7 +228,6 @@ public function getParams()
public function createApplication($type, $arguments = [])
{
try {
$this->initObjectManager();
$application = $this->objectManager->create($type, $arguments);
if (!($application instanceof AppInterface)) {
throw new \InvalidArgumentException("The provided class doesn't implement AppInterface: {$type}");
Expand All @@ -250,7 +250,6 @@ public function run(AppInterface $application)
try {
\Magento\Framework\Profiler::start('magento');
$this->initErrorHandler();
$this->initObjectManager();
$this->assertMaintenance();
$this->assertInstalled();
$response = $application->launch();
Expand Down Expand Up @@ -279,7 +278,6 @@ protected function assertMaintenance()
if (null === $isExpected) {
return;
}
$this->initObjectManager();
/** @var \Magento\Framework\App\MaintenanceMode $maintenance */
$this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class);

Expand Down Expand Up @@ -312,7 +310,6 @@ protected function assertInstalled()
if (null === $isExpected) {
return;
}
$this->initObjectManager();
$isInstalled = $this->isInstalled();
if (!$isInstalled && $isExpected) {
$this->errorCode = self::ERR_IS_INSTALLED;
Expand Down Expand Up @@ -351,7 +348,6 @@ private function getIsExpected($key, $default)
*/
private function isInstalled()
{
$this->initObjectManager();
/** @var \Magento\Framework\App\DeploymentConfig $deploymentConfig */
$deploymentConfig = $this->objectManager->get(\Magento\Framework\App\DeploymentConfig::class);
return $deploymentConfig->isAvailable();
Expand All @@ -364,7 +360,6 @@ private function isInstalled()
*/
public function getObjectManager()
{
$this->initObjectManager();
return $this->objectManager;
}

Expand All @@ -378,20 +373,7 @@ private function initErrorHandler()
$handler = new ErrorHandler();
set_error_handler([$handler, 'handler']);
}

/**
* Initializes object manager
*
* @return void
*/
private function initObjectManager()
{
if (!$this->objectManager) {
$this->objectManager = $this->factory->create($this->server);
$this->maintenance = $this->objectManager->get(\Magento\Framework\App\MaintenanceMode::class);
}
}


/**
* Getter for error code
*
Expand Down

0 comments on commit c7340ee

Please sign in to comment.