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


PHP Url::getPath方法代码示例

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


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

示例1: sendBackgroundGetRequest

 /**
  * Funkce pro odeslání GET požadavku bez čekání na získání odpovědi
  * @param string $url
  * @throws \Exception
  */
 public static function sendBackgroundGetRequest($url)
 {
     $url = new Url($url);
     $host = $url->getHost();
     if (empty($host)) {
         $host = 'localhost';
     }
     #region parametry připojení
     switch ($url->getScheme()) {
         case 'https':
             $scheme = 'ssl://';
             $port = 443;
             break;
         case 'http':
         default:
             $scheme = '';
             $port = 80;
     }
     $urlPort = $url->getPort();
     if (!empty($urlPort)) {
         $port = $urlPort;
     }
     #endregion
     $fp = @fsockopen($scheme . $host, $port, $errno, $errstr, self::REQUEST_TIMEOUT);
     if (!$fp) {
         Debugger::log($errstr, ILogger::ERROR);
         throw new \Exception($errstr, $errno);
     }
     $path = $url->getPath() . ($url->getQuery() != "" ? '?' . $url->getQuery() : '');
     fputs($fp, "GET " . $path . " HTTP/1.0\r\nHost: " . $host . "\r\n\r\n");
     fputs($fp, "Connection: close\r\n");
     fputs($fp, "\r\n");
 }
开发者ID:kizi,项目名称:easyminer-easyminercenter,代码行数:38,代码来源:RequestHelper.php

示例2: getVideoByUrl

 /**
  * Fetches video data by youtube url
  * @param  string  $videoUrl YouTube url
  * @return Video
  */
 public function getVideoByUrl($videoUrl)
 {
     $url = new Nette\Http\Url($videoUrl);
     if (stripos($url->host, 'youtu.be') !== false) {
         return $this->getVideo(trim($url->getPath(), '/'));
     }
     $videoId = $url->getQueryParameter('v');
     if (stripos($url->host, 'youtube.com') === false || $videoId === null) {
         throw new Nette\InvalidArgumentException('videoUrl must be valid youtube url.');
     }
     return $this->getVideo($videoId);
 }
开发者ID:nextras,项目名称:youtube-api,代码行数:17,代码来源:Reader.php

示例3: constructUrl

 /**
  * Constructs absolute URL from Request object.
  * @return string|NULL
  */
 public function constructUrl(array $params, Nette\Http\Url $refUrl)
 {
     if ($this->flags & self::ONE_WAY) {
         return NULL;
     }
     // remove default values; NULL values are retain
     foreach ($this->defaults as $key => $value) {
         if (isset($params[$key]) && $params[$key] == $value) {
             // intentionally ==
             unset($params[$key]);
         }
     }
     $url = ($this->flags & self::SECURED ? 'https://' : $refUrl->getScheme() . '://') . $refUrl->getAuthority() . $refUrl->getPath();
     $sep = ini_get('arg_separator.input');
     $query = http_build_query($params, '', $sep ? $sep[0] : '&');
     if ($query != '') {
         // intentionally ==
         $url .= '?' . $query;
     }
     return $url;
 }
开发者ID:nette,项目名称:routing,代码行数:25,代码来源:SimpleRouter.php

示例4: constructUrl

 /**
  * Constructs absolute URL from Request object.
  *
  * @param  Nette\Application\Request
  * @param  Nette\Http\Url
  *
  * @return string|NULL
  */
 public function constructUrl(Application\Request $appRequest, Nette\Http\Url $refUrl)
 {
     if ($this->flags & self::ONE_WAY) {
         return null;
     }
     $params = $appRequest->getParameters();
     // presenter name
     $presenter = $appRequest->getPresenterName();
     if (strncasecmp($presenter, $this->module, strlen($this->module)) === 0) {
         $params[self::PRESENTER_KEY] = substr($presenter, strlen($this->module));
     } else {
         return null;
     }
     // remove default values; NULL values are retain
     foreach ($this->defaults as $key => $value) {
         if (isset($params[$key]) && $params[$key] == $value) {
             // intentionally ==
             unset($params[$key]);
         }
     }
     $url = ($this->flags & self::SECURED ? 'https://' : 'http://') . $refUrl->getAuthority() . $refUrl->getPath();
     $sep = ini_get('arg_separator.input');
     $query = http_build_query($params, '', $sep ? $sep[0] : '&');
     if ($query != '') {
         // intentionally ==
         $url .= '?' . $query;
     }
     return $url;
 }
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:37,代码来源:SimpleRouter.php

示例5: getSignatureBaseString

 /**
  * Returns the base string of this request
  *
  * The base string defined as the method, the url
  * and the parameters (normalized), each urlencoded
  * and the concated with &
  */
 public function getSignatureBaseString()
 {
     $parts = [$this->method, $this->url->getHostUrl() . $this->url->getPath(), $this->getSignableParameters()];
     return implode('&', OAuth\Utils\Url::urlEncodeRFC3986($parts));
 }
开发者ID:pkristian,项目名称:flickrlickr,代码行数:12,代码来源:Request.php

示例6: constructUrl

 /**
  * @param Request $appRequest
  * @param Url $refUrl
  * @return null|string
  */
 public function constructUrl(Request $appRequest, Url $refUrl)
 {
     // one way can't generate link
     if ($this->options['oneWay']) {
         return NULL;
     }
     $params = $this->clearParameters($appRequest->getParameters());
     $action = new Action($appRequest->getPresenterName() . ':' . $appRequest->getParameter('action'), $params);
     // ISource return NULL, not found url to generate
     if (($seoUrl = $this->source->toUrl($action)) === NULL) {
         return NULL;
     }
     if (!$seoUrl instanceof Url) {
         $seoUrl = new Url($seoUrl);
     }
     // host
     if ($seoUrl->getHost()) {
         $host = $refUrl->getHost();
         $parts = ip2long($host) ? [$host] : array_reverse(explode('.', $host));
         $host = strtr($seoUrl->getHost(), ['%tld%' => $parts[0], '%domain%' => isset($parts[1]) ? "{$parts['1']}.{$parts['0']}" : $parts[0], '%sld%' => isset($parts[1]) ? $parts[1] : '', '%host%' => $refUrl->getHost()]);
     } else {
         $host = $refUrl->getHost();
     }
     // path
     $path = $seoUrl->getPath();
     // query
     $query = $seoUrl->getQueryParameters() + $params;
     ksort($query);
     $seoUrl->setQuery($query);
     $query = $seoUrl->getQuery();
     // fragment
     $fragment = $seoUrl->getFragment();
     return ($this->options['secured'] ? 'https' : 'http') . '://' . $host . $refUrl->getBasePath() . ($path === '/' ? '' : $path) . ($query ? '?' . $query : '') . ($fragment ? '#' . $fragment : '');
 }
开发者ID:Myiyk,项目名称:seo-router,代码行数:39,代码来源:Router.php

示例7: constructUrl

 /**
  * Constructs absolute URL from Request object.
  *
  * @return string|NULL
  */
 public function constructUrl(App\Request $appRequest, Http\Url $refUrl)
 {
     $params = $appRequest->getParameters();
     $query = $params;
     unset($query['action'], $query['page_id'], $query['slug'], $query['id'], $query['locale'], $query['prefix']);
     if (isset($params['slug'])) {
         $slug = strtolower($params['slug']);
     } else {
         if (isset($params['page_id'])) {
             $row = $this->slugManager->getSlugById($params['page_id']);
             // todo peekay Change cs for selected language
             if (isset($query['locale'])) {
                 unset($params['locale']);
             }
             if ($row) {
                 if (isset($params['locale'])) {
                     $slug = $row->{'slug_' . $params['locale']};
                 } else {
                     $slug = $row->{'slug'};
                 }
             } else {
                 return NULL;
             }
         } else {
             return NULL;
         }
     }
     if (isset($params['locale'])) {
         $locale = $params['locale'] . '/';
     } else {
         $locale = null;
     }
     if (isset($params['prefix'])) {
         $prefix = $params['prefix'] . '/';
     } else {
         $prefix = null;
     }
     $url = $refUrl->getScheme() . '://' . $refUrl->getHost() . $refUrl->getPath() . $locale . $prefix . $slug;
     $params = $appRequest->getParameters();
     if (isset($params['action']) && $params['action'] !== 'default') {
         $url .= $refUrl->getPath();
     }
     if (isset($params['id'])) {
         if ($params['action'] == 'default' && isset($params['action'])) {
             $url .= $refUrl->getPath();
         }
         $url .= $refUrl->getPath() . $params['id'];
     }
     if (count($query) > 0) {
         $queryString = '?';
         foreach ($query as $key => $parameter) {
             $queryString .= $key . '=' . $parameter . '&';
         }
         $finalQueryString = substr($queryString, 0, -1);
         $url .= $finalQueryString;
     }
     return $url;
 }
开发者ID:caloriscz,项目名称:caloriscms,代码行数:63,代码来源:SlugRouter.php

示例8:

Application\Request($presenter,$httpRequest->getMethod(),$params,$httpRequest->getPost(),$httpRequest->getFiles(),array(Application\Request::SECURED=>$httpRequest->isSecured()));}function
constructUrl(Application\Request$appRequest,Nette\Http\Url$refUrl){if($this->flags&self::ONE_WAY){return
NULL;}$params=$appRequest->getParameters();$presenter=$appRequest->getPresenterName();if(strncasecmp($presenter,$this->module,strlen($this->module))===0){$params[self::PRESENTER_KEY]=substr($presenter,strlen($this->module));}else{return
NULL;}foreach($this->defaults
as$key=>$value){if(isset($params[$key])&&$params[$key]==$value){unset($params[$key]);}}$url=($this->flags&self::SECURED?'https://':'http://').$refUrl->getAuthority().$refUrl->getPath();$sep=ini_get('arg_separator.input');$query=http_build_query($params,'',$sep?$sep[0]:'&');if($query!=''){$url.='?'.$query;}return$url;}function
开发者ID:JanTvrdik,项目名称:NetteExtras,代码行数:5,代码来源:loader.php

示例9: send

 /**
  * Send request
  *
  * @param string|null $resource Optional resource
  * @param string|null $action   Optional action
  * @param array|null  $values   Optional values
  * @param string|null $method   Optional method
  *
  * @return array
  */
 public function send($resource = null, $action = null, $values = null, $method = null)
 {
     if ($resource) {
         $this->setResource($resource);
     }
     if ($action) {
         $this->setAction($action);
     }
     if ($method) {
         $this->setMethod($method);
     }
     if ($values) {
         $this->setValues($values);
     }
     if ($this->method === self::POST || $this->method === self::PUT) {
         $content = $this->values;
         $url = new Url();
         $url->setPath($this->getResource());
         $url->setQuery(['action' => $this->getAction()]);
     } else {
         $content = [];
         $url = new Url();
         $url->setPath($this->getResource());
         $url->setQuery(array_merge(['action' => $this->getAction()], $this->getValues()));
     }
     $result = $this->adapter->query($url->getPath() . '?' . $url->getQuery(), $this->method, $content);
     if ($result->success === false) {
         throw new Exception\AdapterException(json_encode($result->messages), (string) $url);
     }
     if (!isset($result->body)) {
         throw new Exception\AdapterException('Body not provided in response!', (string) $url);
     }
     return ArrayUtils::objectToArray($result->body);
 }
开发者ID:bauer01,项目名称:unimapper-nette,代码行数:44,代码来源:CustomRequest.php


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