本文整理汇总了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;
}