-
-
Save tiagosampaio/c6b98e0b2e95733ad4f6c04a1d55b436 to your computer and use it in GitHub Desktop.
Magento 2 - Request Flow / Bootstrap - Magento\Framework\App\Http::launch()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
... | |
/** | |
* Run application | |
* | |
* @throws \InvalidArgumentException | |
* @return ResponseInterface | |
*/ | |
public function launch() | |
{ | |
$areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName()); | |
$this->_state->setAreaCode($areaCode); | |
$this->_objectManager->configure($this->_configLoader->load($areaCode)); | |
/** @var \Magento\Framework\App\FrontControllerInterface $frontController */ | |
$frontController = $this->_objectManager->get('Magento\Framework\App\FrontControllerInterface'); | |
$result = $frontController->dispatch($this->_request); | |
// TODO: Temporary solution until all controllers return ResultInterface (MAGETWO-28359) | |
if ($result instanceof ResultInterface) { | |
$this->registry->register('use_page_cache_plugin', true, true); | |
$result->renderResult($this->_response); | |
} elseif ($result instanceof HttpInterface) { | |
$this->_response = $result; | |
} else { | |
throw new \InvalidArgumentException('Invalid return type'); | |
} | |
// This event gives possibility to launch something before sending output (allow cookie setting) | |
$eventParams = ['request' => $this->_request, 'response' => $this->_response]; | |
$this->_eventManager->dispatch('controller_front_send_response_before', $eventParams); | |
return $this->_response; | |
} | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment