本文整理匯總了PHP中Magento\Framework\App\Request\Http::getFrontName方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::getFrontName方法的具體用法?PHP Http::getFrontName怎麽用?PHP Http::getFrontName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\App\Request\Http
的用法示例。
在下文中一共展示了Http::getFrontName方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: launch
/**
* Run application
*
* @return ResponseInterface
*/
public function launch()
{
$areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
$this->_state->setAreaCode($areaCode);
$this->_objectManager->configure($this->_configLoader->load($areaCode));
$this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request);
// This event gives possibility to launch something before sending output (allow cookie setting)
$eventParams = array('request' => $this->_request, 'response' => $this->_response);
$this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
return $this->_response;
}
示例2: launch
/**
* Run application
*
* @return ResponseInterface
*/
public function launch()
{
try {
$areaCode = $this->_areaList->getCodeByFrontName($this->_request->getFrontName());
$this->_state->setAreaCode($areaCode);
$this->_objectManager->configure($this->_configLoader->load($areaCode));
$this->_response = $this->_objectManager->get('Magento\\Framework\\App\\FrontControllerInterface')->dispatch($this->_request);
// This event gives possibility to launch something before sending output (allow cookie setting)
$eventParams = array('request' => $this->_request, 'response' => $this->_response);
$this->_eventManager->dispatch('controller_front_send_response_before', $eventParams);
} catch (\Exception $exception) {
$message = $exception->getMessage() . "\n";
try {
if ($this->_state->getMode() == State::MODE_DEVELOPER) {
$message .= '<pre>';
$message .= $exception->getMessage() . "\n\n";
$message .= $exception->getTraceAsString();
$message .= '</pre>';
} else {
$reportData = array($exception->getMessage(), $exception->getTraceAsString());
// retrieve server data
if (isset($_SERVER)) {
if (isset($_SERVER['REQUEST_URI'])) {
$reportData['url'] = $_SERVER['REQUEST_URI'];
}
if (isset($_SERVER['SCRIPT_NAME'])) {
$reportData['script_name'] = $_SERVER['SCRIPT_NAME'];
}
}
require_once $this->_filesystem->getPath(Filesystem::PUB_DIR) . '/errors/report.php';
$processor = new \Magento\Framework\Error\Processor($this->_response);
$processor->saveReport($reportData);
$this->_response = $processor->processReport();
}
} catch (\Exception $exception) {
$message .= "Unknown error happened.";
}
$this->_response->setHttpResponseCode(500);
$this->_response->setBody($message);
}
return $this->_response;
}
示例3: launch
/**
* 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;
}
示例4: testGetFrontName
public function testGetFrontName()
{
$uri = 'http://test.com/one/two';
$this->_model = $this->getModel($uri);
$this->assertEquals('one', $this->_model->getFrontName());
}
示例5: testGetFrontName
public function testGetFrontName()
{
$this->_model = new Request($this->_routerListMock, $this->_infoProcessorMock, 'http://test.com/one/two');
$this->assertEquals('one', $this->_model->getFrontName());
}