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


PHP Request::getUri方法代码示例

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


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

示例1: createService

 /**
  * Create controller
  *
  * @param ControllerManager $serviceLocator
  * @return Contentinum\Controller\ApplicationController
  */
 public function createService(ServiceLocatorInterface $controllerManager)
 {
     $sl = $controllerManager->getServiceLocator();
     /**
      *
      * @var Contentinum\Options\PageOptions $pageOptions Contentinum\Options\PageOptions
      */
     $pageOptions = $sl->get('User\\PageOptions');
     $request = new HttpRequest();
     $pageOptions->setHost($request->getUri()->getHost());
     $pageOptions->setQuery($request->getUri()->getPath());
     $preferences = $sl->get('Contentinum\\Preference');
     $pageOptions->addPageOptions($preferences);
     $pageOptions->addPageOptions($preferences, $pageOptions->getHost());
     $pages = $sl->get('Contentinum\\PublicPages');
     $pages = is_array($pages) ? $pages : $pages->toArray();
     $pages = isset($pages[$pageOptions->getStdParams()]) ? $pages[$pageOptions->getStdParams()] : array();
     $attribute = $sl->get('Contentinum\\AttributePages');
     $attribute = is_array($attribute) ? $attribute : $attribute->toArray();
     $url = $pageOptions->split($pageOptions->getQuery(), 3);
     if (strlen($url) == 0) {
         $url = 'index';
     }
     if (isset($pages[$url])) {
         $pageOptions->addPageOptions($pages, $url);
         $page = $pages[$url];
     } else {
         $defaultPages = $sl->get('User\\Pages');
         $defaultPages = is_array($defaultPages) ? $defaultPages : $defaultPages->toArray();
         if (isset($defaultPages[$url])) {
             $pageOptions->addPageOptions($defaultPages, $url);
             $page = $defaultPages[$url];
             $page['parentPage'] = 0;
             $page['id'] = 0;
         } else {
             $ctrl = new \Contentinum\Controller\ErrorController();
             $ctrl->setMessage('The desired page is not available!');
             return $ctrl;
         }
     }
     isset($attribute[$page['parentPage']]) ? $pageOptions->addPageOptions($attribute, $page['parentPage']) : false;
     isset($attribute[$page['id']]) ? $pageOptions->addPageOptions($attribute, $page['id']) : false;
     $em = $sl->get($pageOptions->getAppOption('entitymanager'));
     $workerName = $pageOptions->getAppOption('worker');
     $worker = new $workerName($em);
     $worker->setSl($sl);
     $entityName = $pageOptions->getAppOption('entity');
     $worker->setEntity(new $entityName());
     $controller = new McuserController($pageOptions, $page);
     $controller->setWorker($worker);
     return $controller;
 }
开发者ID:jochum-mediaservices,项目名称:contentinum5.5,代码行数:58,代码来源:McuserControllerFactory.php

示例2: __invoke

 /**
  * Generates an url with the given path.
  *
  * @param string $path Path
  *
  * @return string  Url
  */
 public function __invoke($path)
 {
     if ($this->basePath === null) {
         $scheme = $this->request->getUri()->getScheme();
         if ($this->config->getValue('force_frontend_ssl') or $scheme === 'https') {
             $basePath = $this->config->getValue('secure_cdn_base_path');
         } else {
             $basePath = $this->config->getValue('unsecure_cdn_base_path');
         }
         $this->basePath = rtrim($basePath, '/');
     }
     return $this->basePath . '/' . ltrim($path, '/');
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:20,代码来源:Cdn.php

示例3: checkURL

 private function checkURL()
 {
     $url = parent::getUri()->getPath();
     $get = parent::getQuery()->toArray();
     $explodeUrl = explode('/', $url);
     array_shift($explodeUrl);
     array_shift($explodeUrl);
     if (empty($explodeUrl[0])) {
         throw new \Exception('Empty Resource');
     }
     $this->resourse = $explodeUrl[0];
     array_shift($explodeUrl);
     $max = count($explodeUrl);
     for ($i = 0; $i < $max; $i += 2) {
         $name = $explodeUrl[$i];
         if (empty($name)) {
             continue;
         }
         if (!$this->checkParamName($name)) {
             throw new \Exception('Invalid Parameter Name (' . $name . ')');
         }
         $value = isset($explodeUrl[$i + 1]) ? $explodeUrl[$i + 1] : null;
         $this->urlParameters[$name] = urldecode($value);
     }
     foreach ($get as $name => $value) {
         if (!$this->checkParamName($name)) {
             throw new \Exception('Invalid Parameter Name (' . $name . ')');
         }
     }
     $this->urlParameters = array_merge($this->urlParameters, $get);
 }
开发者ID:rockeinstein,项目名称:library,代码行数:31,代码来源:ApiRequestImp.php

示例4: __construct

 /**
  * Initialize proxy with config
  *
  * @param    Config    $config
  */
 public function __construct(Config $config, ZendLogger $logger, Request $request)
 {
     $this->config = $config;
     $this->logger = $logger;
     $trustedProxies = explode(',', $this->config->get('TrustedProxy')->get('loadbalancer'));
     // Populate client info properties from request
     $RemoteAddress = new RemoteAddress();
     $RemoteAddress->setUseProxy();
     $RemoteAddress->setTrustedProxies($trustedProxies);
     $ipAddress = $RemoteAddress->getIpAddress();
     $this->clientIp = array('IPv4' => $ipAddress);
     $Request = new Request();
     $this->clientUri = $Request->getUri();
 }
开发者ID:htw-pk15,项目名称:vufind,代码行数:19,代码来源:TargetsProxy.php

示例5: __invoke

 /**
  * This function will generate all meta tags needed for SEO optimisation.
  *
  * @param array $content
  */
 public function __invoke(array $content = [])
 {
     $description = !empty($content['description']) ? $content['description'] : $this->settings->__invoke('general', 'site_description');
     $keywords = !empty($content['keywords']) ? $content['keywords'] : $this->settings->__invoke('general', 'site_keywords');
     $text = !empty($content['text']) ? $content['text'] : $this->settings->__invoke('general', 'site_text');
     $preview = !empty($content['preview']) ? $content['preview'] : '';
     $title = !empty($content['title']) ? $content['title'] : $this->settings->__invoke('general', 'site_name');
     $this->placeholder->append("\r\n<meta itemprop='name' content='" . $this->settings->__invoke('general', 'site_name') . "'>\r\n");
     // must be set from db
     $this->placeholder->append("<meta itemprop='description' content='" . substr(strip_tags($text), 0, 150) . "'>\r\n");
     $this->placeholder->append("<meta itemprop='title' content='" . $title . "'>\r\n");
     $this->placeholder->append("<meta itemprop='image' content='" . $preview . "'>\r\n");
     $this->headMeta->appendName('keywords', $keywords);
     $this->headMeta->appendName('description', $description);
     $this->headMeta->appendName('viewport', 'width=device-width, initial-scale=1.0');
     $this->headMeta->appendName('generator', $this->settings->__invoke('general', 'site_name'));
     $this->headMeta->appendName('apple-mobile-web-app-capable', 'yes');
     $this->headMeta->appendName('application-name', $this->settings->__invoke('general', 'site_name'));
     $this->headMeta->appendName('mobile-web-app-capable', 'yes');
     $this->headMeta->appendName('HandheldFriendly', 'True');
     $this->headMeta->appendName('MobileOptimized', '320');
     $this->headMeta->appendName('apple-mobile-web-app-status-bar-style', 'black-translucent');
     $this->headMeta->appendName('author', 'Stanimir Dimitrov - stanimirdim92@gmail.com');
     $this->headMeta->appendName('twitter:card', 'summary');
     $this->headMeta->appendName('twitter:site', '@' . $this->settings->__invoke('general', 'site_name'));
     $this->headMeta->appendName('twitter:title', substr(strip_tags($title), 0, 70));
     // max 70 chars
     $this->headMeta->appendName('twitter:description', substr(strip_tags($text), 0, 200));
     $this->headMeta->appendName('twitter:image', $preview);
     // max 1MB
     $this->headMeta->appendProperty('og:image', $preview);
     $this->headMeta->appendProperty('og:title', $title);
     $this->headMeta->appendProperty('og:description', $description);
     $this->headMeta->appendProperty('og:type', 'article');
     $this->headMeta->appendProperty('og:url', $this->request->getUri()->getHost() . $this->request->getRequestUri());
 }
开发者ID:samsonasik,项目名称:unnamed,代码行数:41,代码来源:InitMetaTags.php

示例6: testServerHostnameProvider

 /**
  * @dataProvider serverHostnameProvider
  * @param array  $server
  * @param string $name
  * @param string $value
  */
 public function testServerHostnameProvider(array $server, $expectedHost, $expectedRequestUri)
 {
     $_SERVER = $server;
     $request = new Request();
     $host = $request->getUri()->getHost();
     $this->assertEquals($expectedHost, $host);
     $requestUri = $request->getRequestUri();
     $this->assertEquals($expectedRequestUri, $requestUri);
 }
开发者ID:Rovak,项目名称:zf2,代码行数:15,代码来源:RequestTest.php

示例7: _getRelativePath

 /**
  * Get the URI path of the request, relative to the application base URL.
  *
  * @param HttpRequest $request
  * @return string
  */
 protected function _getRelativePath(HttpRequest $request)
 {
     $basePath = $request->getBasePath();
     $relPath = $request->getUri()->getPath();
     if (!empty($basePath) && strpos($relPath, $basePath) === 0) {
         $relPath = substr($relPath, strlen($basePath));
     }
     return $relPath;
 }
开发者ID:VictorAlencar,项目名称:zf2-oauth2-provider,代码行数:15,代码来源:AuthenticationListener.php

示例8: testServerHostnameProvider

 /**
  * @dataProvider serverHostnameProvider
  * @param array  $server
  * @param string $name
  * @param string $value
  */
 public function testServerHostnameProvider(array $server, $expectedHost, $expectedPort, $expectedRequestUri)
 {
     $_SERVER = $server;
     $request = new Request();
     $host = $request->getUri()->getHost();
     $this->assertEquals($expectedHost, $host);
     $uriParts = parse_url($_SERVER['REQUEST_URI']);
     if (isset($uriParts['scheme'])) {
         $scheme = $request->getUri()->getScheme();
         $this->assertEquals($uriParts['scheme'], $scheme);
     }
     $port = $request->getUri()->getPort();
     $this->assertEquals($expectedPort, $port);
     $requestUri = $request->getRequestUri();
     $this->assertEquals($expectedRequestUri, $requestUri);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:22,代码来源:RequestTest.php

示例9: createService

 /**
  * Create controller
  *
  * @param ControllerManager $serviceLocator
  * @return Contentinum\Controller\ApplicationController
  */
 public function createService(ServiceLocatorInterface $controllerManager)
 {
     $sl = $controllerManager->getServiceLocator();
     /**
      *
      * @var $pageOptions Contentinum\Options\PageOptions
      */
     $pageOptions = $sl->get('contentinum_pages');
     $opt = $sl->get('contentinum_customer');
     if (isset($opt['default']['google_map_apikey'])) {
         define('GOOGLE_API_KEY', $opt['default']['google_map_apikey']);
     }
     $request = new HttpRequest();
     $pageOptions->setHost($request->getUri()->getHost());
     $pageOptions->setQuery($request->getUri()->getPath());
     $pageOptions->setProtocol($request->getUri()->getScheme());
     $pagefiles = $sl->get('contentinum_page_files');
     $page = $pageOptions->split();
     $defaults = $sl->get('contentinum_page_defaults');
     if (isset($pagefiles[$page . '_pages'])) {
         $defaults->setCacheKey($page . '_pages');
         $pages = $defaults->get($pagefiles[$page . '_pages']);
         $pageOptions->addOptions($pages);
         if (isset($pages[$pageOptions->getQuery()])) {
             $pageOptions->addOptions($pages, '/' . $pageOptions->split(null, 5), true);
             $pageOptions->setActive('/' . $pageOptions->split(null, 5));
         } else {
             switch ($page) {
                 case 'mcevent':
                 case 'mcwork':
                 case 'municipal':
                 case 'feuerwehr':
                 case 'guestbook':
                 case 'newsletter':
                     if (isset($pages['/' . $pageOptions->split(null, 3)])) {
                         $pageOptions->addOptions($pages, '/' . $pageOptions->split(null, 3), true);
                         $pageOptions->setActive('/' . $pageOptions->split(null, 3));
                     } elseif (isset($pages['/' . $pageOptions->split(null, $pageOptions->getSplitQuery())])) {
                         // ... or isset page ...
                         $pageOptions->addOptions($pages, '/' . $pageOptions->split(null, $pageOptions->getSplitQuery()), true);
                         $pageOptions->setActive('/' . $pageOptions->split(null, $pageOptions->getSplitQuery()));
                     } else {
                         // ... page not found send 404
                         die('not found');
                     }
                     break;
                 default:
                     die('not found');
                     break;
             }
         }
     } elseif (in_array($page, array('login', 'logout'))) {
         $defaults->setCacheKey('mcuser_pages');
         $pages = $defaults->get($pagefiles['mcuser_pages']);
         $pageOptions->addOptions($pages);
         // default options
         $pageOptions->addOptions($pages, '/' . $pageOptions->split(null, 2), true);
         $pageOptions->setActive('/' . $pageOptions->split(null, 2));
     } else {
         $defaults->setCacheKey('app_pages');
         $pageOptions->addOptions($defaults->get($pagefiles['app_pages']));
         $url = $pageOptions->split($pageOptions->getQuery(), 1);
         switch ($url) {
             case 'sitemap.xml':
             case 'feed':
             case 'pdf':
             case 'emailrecom':
             case 'contentplugin':
                 $pageOptions->addOptions($defaults->get($pagefiles['app_pages']), $url);
                 break;
             default:
                 $preferences = $sl->get('contentinum_preference');
                 $pageOptions->addOptions($preferences);
                 $pageOptions->addOptions($preferences, $pageOptions->getHost());
                 $pages = $sl->get('contentinum_public_pages');
                 $hostId = $pageOptions->getHostId();
                 if (strlen($url) == 0) {
                     $url = 'index';
                 }
                 if (null !== ($page = $pages->{$hostId}->{$url})) {
                     $attribute = $sl->get('contentinum_attribute_pages');
                     $attribute = is_array($attribute) ? $attribute : $attribute->toArray();
                     isset($attribute[$page['parentPage']]) ? $pageOptions->addOptions($attribute, $page['parentPage']) : false;
                     isset($attribute[$page['id']]) ? $pageOptions->addOptions($attribute, $page['id']) : false;
                     $pageHeaders = $sl->get('contentinum_page_headers');
                     isset($pageHeaders[$page['parentPage']]) ? $pageOptions->addPageHeaders($pageHeaders, $page['parentPage']) : false;
                     isset($pageHeaders[$page['id']]) ? $pageOptions->addPageHeaders($pageHeaders, $page['id']) : false;
                     $pageOptions->addPage($page);
                 } else {
                     $preferences = $sl->get('contentinum_preference');
                     $pageOptions->addOptions($preferences);
                     $pageOptions->addOptions($preferences, $pageOptions->getHost());
                     $pages = $sl->get('contentinum_public_pages');
                     $hostId = $pageOptions->getHostId();
//.........这里部分代码省略.........
开发者ID:jochum-mediaservices,项目名称:contentinum5.5,代码行数:101,代码来源:ApplicationControllerFactory.php


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