本文整理匯總了PHP中Magento\Framework\App\Request\Http::getDistroBaseUrlPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP Http::getDistroBaseUrlPath方法的具體用法?PHP Http::getDistroBaseUrlPath怎麽用?PHP Http::getDistroBaseUrlPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\App\Request\Http
的用法示例。
在下文中一共展示了Http::getDistroBaseUrlPath方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getUrl
/**
* Gets setup application URL
*
* @return string
*/
public function getUrl()
{
if (isset($this->server[self::PARAM_NOT_INSTALLED_URL])) {
return $this->server[self::PARAM_NOT_INSTALLED_URL];
}
return Request\Http::getDistroBaseUrlPath($this->server) . $this->getPath() . '/';
}
示例2: testGetDistroBaseUrlPath
/**
* @param string $scriptName
* @param string $expected
* @dataProvider getDistroBaseUrlPathDataProvider
*/
public function testGetDistroBaseUrlPath($scriptName, $expected)
{
$this->assertEquals($expected, Http::getDistroBaseUrlPath(['SCRIPT_NAME' => $scriptName]));
}
示例3: authPreDispatch
/**
* Check if user login
*
* @param \Zend\Mvc\MvcEvent $event
* @return bool
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function authPreDispatch($event)
{
/** @var RouteMatch $routeMatch */
$routeMatch = $event->getRouteMatch();
$controller = $routeMatch->getParam('controller');
if (!in_array($controller, $this->controllersToSkip)) {
/** @var Application $application */
$application = $event->getApplication();
$serviceManager = $application->getServiceManager();
if ($serviceManager->get('Magento\\Framework\\App\\DeploymentConfig')->isAvailable()) {
/** @var \Magento\Setup\Model\ObjectManagerProvider $objectManagerProvider */
$objectManagerProvider = $serviceManager->get('Magento\\Setup\\Model\\ObjectManagerProvider');
/** @var \Magento\Framework\ObjectManagerInterface $objectManager */
$objectManager = $objectManagerProvider->get();
/** @var \Magento\Framework\App\State $adminAppState */
$adminAppState = $objectManager->get('Magento\\Framework\\App\\State');
$adminAppState->setAreaCode(\Magento\Framework\App\Area::AREA_ADMIN);
/** @var \Magento\Backend\Model\Session\AdminConfig $sessionConfig */
$sessionConfig = $objectManager->get(\Magento\Backend\Model\Session\AdminConfig::class);
$cookiePath = $this->getSetupCookiePath($objectManager);
$sessionConfig->setCookiePath($cookiePath);
/** @var \Magento\Backend\Model\Auth\Session $adminSession */
$adminSession = $objectManager->create(\Magento\Backend\Model\Auth\Session::class, ['sessionConfig' => $sessionConfig, 'appState' => $adminAppState]);
if (!$objectManager->get(\Magento\Backend\Model\Auth::class)->isLoggedIn()) {
$adminSession->destroy();
$response = $event->getResponse();
$baseUrl = Http::getDistroBaseUrlPath($_SERVER);
$response->getHeaders()->addHeaderLine('Location', $baseUrl . 'index.php/session/unlogin');
$response->setStatusCode(302);
$event->stopPropagation();
return $response;
}
}
}
return false;
}