当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getHttpHost方法代码示例

本文整理汇总了PHP中Symfony\Component\HttpFoundation\Request::getHttpHost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getHttpHost方法的具体用法?PHP Request::getHttpHost怎么用?PHP Request::getHttpHost使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\HttpFoundation\Request的用法示例。


在下文中一共展示了Request::getHttpHost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: match

 /**
  *
  * @param Request $request
  * @throws AppException
  * @return ApplicationUri
  */
 public function match($request)
 {
     $found = null;
     $uris = ApplicationUriQuery::create()->joinApplication()->filterByHttphost($request->getHttpHost())->find();
     $requestUri = Text::create($request->getRequestUri())->trimRight('/');
     foreach ($uris as $uri) {
         $basepath = new Text($uri->getBasepath());
         // either request uri and uri basepath are both empty
         // or request uri starts with basepath
         if ($basepath->isEmpty() && $uri->getHttphost() == $request->getHttpHost() || $requestUri->startsWith($basepath)) {
             // assign when it's the first found
             if ($found === null) {
                 $found = $uri;
             } else {
                 if ($basepath->count('/') > Text::create($found->getBasepath())->count('/')) {
                     $found = $uri;
                 }
             }
         }
     }
     if ($found === null) {
         throw new AppException(sprintf('No app found on %s', $request->getUri()), 404);
     }
     $this->destination = str_replace($found->getBasepath(), '', $request->getRequestUri());
     return $found;
 }
开发者ID:keeko,项目名称:framework,代码行数:32,代码来源:ApplicationRouter.php

示例2: __construct

 /**
  * @param Dispatch $dispatcher
  * @param Request  $request
  */
 public function __construct(Dispatch $dispatcher, Request $request)
 {
     $this->_dispatcher = $dispatcher;
     $this->_request = $request;
     $this->_httpHost = $this->_request->getHttpHost();
     $this->_mapper = new DirectoryMapper($dispatcher->getBaseDirectory(), $dispatcher->getConfig());
     $this->_mapper->setHashMap(ValueAs::arr($dispatcher->getConfig()->getItem('hashtable', [])));
 }
开发者ID:packaged,项目名称:dispatch,代码行数:12,代码来源:ResourceGenerator.php

示例3: run

 /**
  * Performs route matching & dispatch and sends the response.
  *
  * @return $this
  */
 public function run()
 {
     // Route
     $match = $this->router->match($this->request->getPathInfo(), $this->request->getMethod(), $this->request->getHttpHost(false));
     // Dispatch
     $this->dispatch($match);
     // Respond
     $this->response->send();
 }
开发者ID:smrtr,项目名称:spawn-point,代码行数:14,代码来源:App.php

示例4: buildForPreprocessor

 public function buildForPreprocessor(Request $request, Route $preprocessorRoute)
 {
     // Localhost case
     if ($preprocessorRoute->getDefault('_http_host') === $request->getHttpHost()) {
         $this->logger->info("InternalForwarder built for preprocessor: Localhost forwarder.", ['host' => $request->getHttpHost()]);
         return $this->container->get('prestashop.public_writer.protocol.internal_forwarder.localhost');
     }
     // Error case: localhost case was not matching, but there is no other forwarder available.
     $this->logger->error("InternalForwarder built for preprocessor: NO forwarder found to reach distant host.", ['host' => $request->getHttpHost()]);
     throw new \ErrorException("InternalForwarder building for preprocessor: NO forwarder found to reach distant host: " . $request->getHttpHost());
 }
开发者ID:xGouley,项目名称:PSPublicWriterBundle,代码行数:11,代码来源:InternalForwarderFactory.php

示例5: serialize

 public function serialize(JsonSerializationVisitor $visitor, OwnerData $owner, array $type)
 {
     $scheme = $this->request->getScheme() . '://' . $this->request->getHttpHost();
     $data = $owner->getData();
     if ($owner->getAvatarFileName()) {
         $data['avatar_file_path'] = $this->uh->asset($owner, 'avatar');
     } else {
         $data['avatar_file_path'] = $scheme . $owner->getDefaultAvatar();
     }
     return $data;
 }
开发者ID:shakaran,项目名称:powerline-server,代码行数:11,代码来源:OwnerDataHandler.php

示例6: lostPasswordAction

 /**
  * @Route("/lostPassword", name="lost_password_route")
  */
 public function lostPasswordAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $reset = false;
     if ($request->request->get('reset') == "true") {
         $reset = true;
     }
     if ($reset) {
         $user = $em->getRepository('BackendBundle:User')->findOneByEmail($request->request->get('email'));
         if (!is_null($user)) {
             $rb = uniqid(rand(), true);
             $random = md5($user->getEmail() . $rb);
             //guardar en la base de datos
             $restorer = $em->getRepository('BackendBundle:Restorer')->findOneByUser($user);
             if (is_null($restorer)) {
                 $restorer = new Restorer();
             }
             $restorer->setUser($user);
             $restorer->setTime(new \DateTime());
             $restorer->setAuth(md5($random));
             $em->persist($restorer);
             $em->flush();
             $baseurl = $request->getScheme() . '://' . $request->getHttpHost() . $request->getBasePath();
             $url = $baseurl . '/resetPassword?token=' . $random;
             $message = \Swift_Message::newInstance()->setSubject('Recuperación de contraseña')->setFrom('gestionIPre@ing.puc.cl')->setTo(array($user->getEmail()))->setBody('<html>' . ' <head></head>' . ' <body>' . ' Hola, usa este link para recuperar tu contraseña: ' . '<a href="' . $url . '">' . $url . '</a></br>' . ' Si no pediste recuperar contraseña omite este email. (No responda este email)</body>' . '</html>', 'text/html');
             $this->get('mailer')->send($message);
         }
     }
     return $this->render('security/lostPassword.html.twig', array('reset' => $reset));
 }
开发者ID:ericksho,项目名称:sigi,代码行数:33,代码来源:SecurityController.php

示例7: archiveIndexAction

 /**
  * @param Request $request
  * @param string $slug
  * @param boolean $isJournalHosting
  * @return Response
  */
 public function archiveIndexAction(Request $request, $slug, $isJournalHosting = false)
 {
     /**
      * @todo we should check if it is base domain initialized
      */
     $currentHost = $request->getHttpHost();
     /*
     $base_host = $container->getParameter('base_host');
     if($currentHost == $base_host){
         $this->throw404IfNotFound(0);
     }
     */
     $em = $this->getDoctrine()->getManager();
     /** @var BlockRepository $blockRepo */
     $blockRepo = $em->getRepository('OjsJournalBundle:Block');
     /** @var Journal $journal */
     $journal = $em->getRepository('OjsJournalBundle:Journal')->findOneBy(['slug' => $slug]);
     $this->throw404IfNotFound($journal);
     if ($journal->getStatus() !== JournalStatuses::STATUS_PUBLISHED || $journal->getPublisher()->getStatus() !== PublisherStatuses::STATUS_COMPLETE) {
         $journal = null;
         $this->throw404IfNotFound($journal);
     }
     $data['groupedIssues'] = $em->getRepository(Issue::class)->getByYear($journal, true);
     $data['page'] = 'archive';
     $data['blocks'] = $blockRepo->journalBlocks($journal);
     $data['journal'] = $journal;
     $data['isJournalHosting'] = $isJournalHosting;
     $data['displayModes'] = ['all' => IssueDisplayModes::SHOW_ALL, 'title' => IssueDisplayModes::SHOW_TITLE, 'volumeAndNumber' => IssueDisplayModes::SHOW_VOLUME_AND_NUMBER];
     return $this->render('OjsSiteBundle::Journal/archive_index.html.twig', $data);
 }
开发者ID:ojs,项目名称:ojs,代码行数:36,代码来源:JournalController.php

示例8: handle

 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     $data = ['request-id' => $request->headers->get('X-Request-Id'), 'datetime' => date('Y-m-d H:i:s'), 'method' => $request->getMethod(), 'scheme' => $request->getScheme(), 'host' => $request->getHttpHost(), 'uri' => $request->getRequestUri(), 'route' => $request->get('_route')];
     /*
     if (isset($this['current_user'])) {
         $data['username'] = $this['current_user']->getName();
     }
     */
     $data['address'] = $request->getClientIp();
     if ($request->getSession()) {
         $data['session-id'] = $request->getSession()->getId();
     }
     if ($request->headers->has('User-Agent')) {
         $data['agent'] = $request->headers->get('User-Agent');
     }
     if ($request->headers->has('referer')) {
         $data['referer'] = $request->headers->get('referer');
     }
     $this->log($data);
     $response = $this->app->handle($request, $type, $catch);
     /*
     // response details
     $data['status'] = $response->getStatusCode();
     if ($response->headers->has('Content-Type')) {
         $data['content-type'] = $response->headers->get('content-type');
     }
     */
     return $response;
 }
开发者ID:Radvance,项目名称:Radvance,代码行数:29,代码来源:RequestLogMiddleware.php

示例9: switchAction

 /**
  * Action for locale switch
  *
  * @param Request $request
  *
  * @throws \InvalidArgumentException
  * @return RedirectResponse
  */
 public function switchAction(Request $request)
 {
     $_locale = $request->attributes->get('_locale', $request->getLocale());
     $statusCode = $request->attributes->get('statusCode', $this->statusCode);
     $useReferrer = $request->attributes->get('useReferrer', $this->useReferrer);
     $redirectToRoute = $request->attributes->get('route', $this->redirectToRoute);
     $metaValidator = $this->metaValidator;
     if (!$metaValidator->isAllowed($_locale)) {
         throw new \InvalidArgumentException(sprintf('Not allowed to switch to locale %s', $_locale));
     }
     // Redirect the User
     if ($useReferrer && $request->headers->has('referer')) {
         $response = new RedirectResponse($request->headers->get('referer'), $statusCode);
     } elseif ($this->router && $redirectToRoute) {
         $target = $this->router->generate($redirectToRoute, array('_locale' => $_locale));
         if ($request->getQueryString()) {
             if (!strpos($target, '?')) {
                 $target .= '?';
             }
             $target .= $request->getQueryString();
         }
         $response = new RedirectResponse($target, $statusCode);
     } else {
         // TODO: this seems broken, as it will not handle if the site runs in a subdir
         // TODO: also it doesn't handle the locale at all and can therefore lead to an infinite redirect
         $response = new RedirectResponse($request->getScheme() . '://' . $request->getHttpHost() . '/', $statusCode);
     }
     return $response;
 }
开发者ID:Sententiaregum,项目名称:LocaleBundle,代码行数:37,代码来源:LocaleController.php

示例10: switchAction

 /**
  * Action for locale switch
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  * @param                                           $_locale The locale to set
  *
  * @return \Symfony\Bundle\FrameworkBundle\Controller\RedirectResponse
  *
  * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function switchAction(Request $request, $_locale)
 {
     // Check if the Language is allowed
     if (!in_array(\Locale::getPrimaryLanguage($_locale), $this->allowedLanguages)) {
         throw new NotFoundHttpException('This language is not available');
     }
     // tries to detect a Region from the user-provided locales
     $providedLanguages = $request->getLanguages();
     $locales = array();
     foreach ($providedLanguages as $locale) {
         if (strpos($locale . '_', $_locale) !== false && strlen($locale) > 2) {
             $locales[] = $locale;
         }
     }
     if (count($locales) > 0) {
         $this->session->set('localeIdentified', $locales[0]);
     } else {
         $this->session->set('localeIdentified', $_locale);
     }
     // Add the listener
     $this->session->set('setLocaleCookie', true);
     // Redirect the User
     if ($request->headers->has('referer') && true === $this->useReferrer) {
         return new RedirectResponse($request->headers->get('referer'));
     }
     if (null !== $this->redirectToRoute) {
         return new RedirectResponse($this->router->generate($this->redirectToRoute));
     }
     return new RedirectResponse($request->getScheme() . '://' . $request->getHttpHost() . $this->redirectToUrl);
 }
开发者ID:rdohms,项目名称:LocaleBundle,代码行数:40,代码来源:LocaleController.php

示例11: indexAction

 public function indexAction(Request $request)
 {
     $form = $request->request->all();
     $no_js = $request->query->get('no-js') || 0;
     $script = $no_js == 1 ? 0 : 1;
     $db_dir = $this->get('kernel')->getBundle('EUREKAG6KBundle', true)->getPath() . "/Resources/data/databases";
     try {
         $this->datasources = new \SimpleXMLElement($db_dir . "/DataSources.xml", LIBXML_NOWARNING, true);
         $datasourcesCount = $this->datasources->DataSource->count();
     } catch (\Exception $e) {
         $datasourcesCount = 0;
     }
     $userManager = $this->get('fos_user.user_manager');
     $users = $userManager->findUsers();
     $finder = new Finder();
     $simu_dir = $this->get('kernel')->getBundle('EUREKAG6KBundle', true)->getPath() . "/Resources/data/simulators";
     $finder->depth('== 0')->files()->name('*.xml')->in($simu_dir);
     $simulatorsCount = $finder->count();
     $finder = new Finder();
     $views_dir = $this->get('kernel')->getBundle('EUREKAG6KBundle', true)->getPath() . "/Resources/views";
     $finder->depth('== 0')->ignoreVCS(true)->exclude(array('admin', 'base', 'Theme'))->directories()->in($views_dir);
     $viewsCount = $finder->count();
     $hiddens = array();
     $hiddens['script'] = $script;
     $silex = new Application();
     $silex->register(new MobileDetectServiceProvider());
     try {
         return $this->render('EUREKAG6KBundle:admin/pages:index.html.twig', array('ua' => $silex["mobile_detect"], 'path' => $request->getScheme() . '://' . $request->getHttpHost(), 'nav' => 'home', 'datasourcesCount' => $datasourcesCount, 'usersCount' => count($users), 'simulatorsCount' => $simulatorsCount, 'viewsCount' => $viewsCount, 'hiddens' => $hiddens));
     } catch (\Exception $e) {
         echo $e->getMessage();
         throw $this->createNotFoundException($this->get('translator')->trans("This template does not exist"));
     }
 }
开发者ID:eureka2,项目名称:g6k,代码行数:33,代码来源:HomeAdminController.php

示例12: build

 /**
  * Return a DIC-IT container, using adapter to respect Pyrite interface.
  *
  * @param Request $request       Current request object.
  * @param string  $containerPath Path to load config from.
  *
  * @return \Pyrite\Container\Container
  */
 public static function build(Request $request, $containerPath)
 {
     $config = new NullConfig();
     if (null !== $containerPath && preg_match('/.*yml$/', $containerPath)) {
         $config = new YML($containerPath);
     }
     if (null !== $containerPath && preg_match('/.*php$/', $containerPath)) {
         $config = new PHP($containerPath);
     }
     $activator = new ActivatorFactory();
     $container = new DICITAdapter($config, $activator);
     $activator->addActivator('security', $container->get('SecurityActivator'), false);
     // initialize the translation engine
     $translationManager = $container->get('TranslationEngine');
     $host = $request->getHttpHost();
     $locale = $container->getParameter('default_locale.' . str_replace('.', '_', $host));
     if ($locale === null) {
         $locale = $container->getParameter('default_locale.default');
     }
     $container->setParameter('current_locale', $locale);
     $translationManager->setLocale($locale);
     $reader = new \Doctrine\Common\Annotations\AnnotationReader();
     \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader(function ($class) {
         return class_exists($class);
     });
     $container->bind('AnnotationReader', $reader);
     $director = $container->get('PyRestDirector');
     $packages = $container->getParameter('crud.packages');
     foreach ($packages as $packageName => $packageConfiguration) {
         $director->buildAll($packageName);
     }
     return $container;
 }
开发者ID:mr-magic-stuff,项目名称:EVFramework,代码行数:41,代码来源:BaseBuilder.php

示例13: clearAction

 public function clearAction(Request $request, $env = 'prod')
 {
     $form = $request->request->all();
     $no_js = $request->query->get('no-js') || 0;
     $script = $no_js == 1 ? 0 : 1;
     if (!$this->get('security.context')->isGranted('ROLE_ADMIN')) {
         throw $this->AccessDeniedException($this->get('translator')->trans("Access Denied!"));
     }
     $cache_dir = dirname($this->get('kernel')->getCacheDir());
     $this->log[] = "<b>" . $this->get('translator')->trans("cache directory : %cachedir%", array('%cachedir%' => $cache_dir)) . "</b>";
     if (is_dir($cache_dir)) {
         if (basename($cache_dir) == "cache") {
             $this->log[] = "<br/><br/><b>" . $this->get('translator')->trans("clearing cache") . " :</b>";
             $this->cc($cache_dir, $env);
             $this->log[] = "<br/><br/><b>" . $this->get('translator')->trans("done !") . "</b>";
         } else {
             $this->log[] = "<br/> " . $this->get('translator')->trans("Error : %cachedir% is not a named cache", array('%cachedir%' => $cache_dir));
         }
     } else {
         $this->log[] = "<br/> " . $this->get('translator')->trans("Error : %cachedir% is not a directory", array('%cachedir%' => $cache_dir));
     }
     $hiddens = array();
     $hiddens['script'] = $script;
     $silex = new Application();
     $silex->register(new MobileDetectServiceProvider());
     try {
         return $this->render('EUREKAG6KBundle:admin/pages:cache-clear.html.twig', array('ua' => $silex["mobile_detect"], 'path' => $request->getScheme() . '://' . $request->getHttpHost(), 'nav' => 'caches', 'log' => $this->log, 'hiddens' => $hiddens));
     } catch (\Exception $e) {
         throw $this->createNotFoundException($this->get('translator')->trans("This template does not exist"));
     }
 }
开发者ID:eureka2,项目名称:g6k,代码行数:31,代码来源:CacheAdminController.php

示例14: indexAction

 public function indexAction(Request $request)
 {
     $mobile = $this->setting('mobile', array());
     if (empty($mobile['enabled'])) {
         return $this->createMessageResponse('info', '客户端尚未开启!');
     }
     return $this->render('TopxiaWebBundle:Mobile:index.html.twig', array('host' => $request->getHttpHost()));
 }
开发者ID:styling,项目名称:LeesPharm,代码行数:8,代码来源:MobileController.php

示例15: indexAction

 public function indexAction(Request $request)
 {
     $mobile = $this->setting('mobile', array());
     if (empty($mobile['enabled'])) {
         return $this->createMessageResponse('info', '客户端尚未开启!');
     }
     $result = CloudAPIFactory::create('leaf')->get('/me');
     return $this->render('TopxiaWebBundle:Mobile:index.html.twig', array('host' => $request->getHttpHost(), 'mobileCode' => array_key_exists("mobileCode", $result) && !empty($result["mobileCode"]) ? $result["mobileCode"] : "edusoho", 'mobile' => $mobile));
 }
开发者ID:nanyi,项目名称:EduSoho,代码行数:9,代码来源:MobileController.php


注:本文中的Symfony\Component\HttpFoundation\Request::getHttpHost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。