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


PHP Http::getPath方法代码示例

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


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

示例1: __call

 /**
  * Method call overload
  *
  * Allows calling REST actions as object methods; however, you must
  * follow-up by chaining the request with a request to an HTTP request
  * method (post, get, delete, put):
  * <code>
  * $response = $rest->sayHello('Foo', 'Manchu')->get();
  * </code>
  *
  * Or use them together, but in sequential calls:
  * <code>
  * $rest->sayHello('Foo', 'Manchu');
  * $response = $rest->get();
  * </code>
  *
  * @param string $method Method name
  * @param array $args Method args
  * @return \Zend\Rest\Client\RestClient_Result|\Zend\Rest\Client\RestClient \Zend\Rest\Client\RestClient if using
  * a remote method, Zend_Rest_Client_Result if using an HTTP request method
  */
 public function __call($method, $args)
 {
     $methods = array('post', 'get', 'delete', 'put');
     if (in_array(strtolower($method), $methods)) {
         if (!isset($args[0])) {
             $args[0] = $this->_uri->getPath();
         }
         $this->_data['rest'] = 1;
         $data = array_slice($args, 1) + $this->_data;
         $response = $this->{'rest' . $method}($args[0], $data);
         $this->_data = array();
         //Initializes for next Rest method.
         return new Result($response->getBody());
     } else {
         // More than one arg means it's definitely a Zend_Rest_Server
         if (sizeof($args) == 1) {
             // Uses first called function name as method name
             if (!isset($this->_data['method'])) {
                 $this->_data['method'] = $method;
                 $this->_data['arg1'] = $args[0];
             }
             $this->_data[$method] = $args[0];
         } else {
             $this->_data['method'] = $method;
             if (sizeof($args) > 0) {
                 foreach ($args as $key => $arg) {
                     $key = 'arg' . $key;
                     $this->_data[$key] = $arg;
                 }
             }
         }
         return $this;
     }
 }
开发者ID:rexmac,项目名称:zf2,代码行数:55,代码来源:RestClient.php

示例2: ingest

 /**
  * Ingest from a URL.
  *
  * Accepts the following non-prefixed keys:
  *
  * + ingest_url: (required) The URL to ingest. The idea is that some URLs
  *   contain sensitive data that should not be saved to the database, such
  *   as private keys. To preserve the URL, remove sensitive data from the
  *   URL and set it to o:source.
  * + store_original: (optional, default true) Whether to store an original
  *   file. This is helpful when you want the media to have thumbnails but do
  *   not need the original file.
  *
  * {@inheritDoc}
  */
 public function ingest(Media $media, Request $request, ErrorStore $errorStore)
 {
     $data = $request->getContent();
     if (!isset($data['ingest_url'])) {
         $errorStore->addError('error', 'No ingest URL specified');
         return;
     }
     $uri = new HttpUri($data['ingest_url']);
     if (!($uri->isValid() && $uri->isAbsolute())) {
         $errorStore->addError('ingest_url', 'Invalid ingest URL');
         return;
     }
     $file = $this->getServiceLocator()->get('Omeka\\File');
     $file->setSourceName($uri->getPath());
     $this->downloadFile($uri, $file->getTempPath());
     $fileManager = $this->getServiceLocator()->get('Omeka\\File\\Manager');
     $hasThumbnails = $fileManager->storeThumbnails($file);
     $media->setHasThumbnails($hasThumbnails);
     if (!isset($data['store_original']) || $data['store_original']) {
         $fileManager->storeOriginal($file);
         $media->setHasOriginal(true);
     }
     $media->setFilename($file->getStorageName());
     $media->setMediaType($file->getMediaType());
     if (!array_key_exists('o:source', $data)) {
         $media->setSource($uri);
     }
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:43,代码来源:Url.php

示例3: ingest

 public function ingest(Media $media, Request $request, ErrorStore $errorStore)
 {
     $data = $request->getContent();
     if (!isset($data['o:source'])) {
         $errorStore->addError('o:source', 'No YouTube URL specified');
         return;
     }
     $uri = new HttpUri($data['o:source']);
     if (!($uri->isValid() && $uri->isAbsolute())) {
         $errorStore->addError('o:source', 'Invalid YouTube URL specified');
         return;
     }
     switch ($uri->getHost()) {
         case 'www.youtube.com':
             if ('/watch' !== $uri->getPath()) {
                 $errorStore->addError('o:source', 'Invalid YouTube URL specified, missing "/watch" path');
                 return;
             }
             $query = $uri->getQueryAsArray();
             if (!isset($query['v'])) {
                 $errorStore->addError('o:source', 'Invalid YouTube URL specified, missing "v" parameter');
                 return;
             }
             $youtubeId = $query['v'];
             break;
         case 'youtu.be':
             $youtubeId = substr($uri->getPath(), 1);
             break;
         default:
             $errorStore->addError('o:source', 'Invalid YouTube URL specified, not a YouTube URL');
             return;
     }
     $fileManager = $this->getServiceLocator()->get('Omeka\\File\\Manager');
     $file = $this->getServiceLocator()->get('Omeka\\File');
     $url = sprintf('http://img.youtube.com/vi/%s/0.jpg', $youtubeId);
     $this->downloadFile($url, $file->getTempPath());
     $hasThumbnails = $fileManager->storeThumbnails($file);
     $media->setData(['id' => $youtubeId, 'start' => $request->getValue('start'), 'end' => $request->getValue('end')]);
     if ($hasThumbnails) {
         $media->setFilename($file->getStorageName());
         $media->setHasThumbnails(true);
     }
 }
开发者ID:patrova,项目名称:omeka-s,代码行数:43,代码来源:Youtube.php

示例4: write

 /**
  * Send request to the remote server with streaming support.
  *
  * @param string        $method
  * @param \Zend\Uri\Http $uri
  * @param string        $http_ver
  * @param array         $headers
  * @param string        $body
  * @return string Request as string
  */
 public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '')
 {
     // Make sure we're properly connected
     if (!$this->socket) {
         throw new Adapter\Exception('Trying to write but we are not connected');
     }
     $host = $uri->getHost();
     $host = (strtolower($uri->getScheme()) == 'https' ? $this->config['ssltransport'] : 'tcp') . '://' . $host;
     if ($this->connected_to[0] != $host || $this->connected_to[1] != $uri->getPort()) {
         throw new Adapter\Exception('Trying to write but we are connected to the wrong host');
     }
     // Save request method for later
     $this->method = $method;
     // Build request headers
     $path = $uri->getPath();
     if ($uri->getQuery()) {
         $path .= '?' . $uri->getQuery();
     }
     $request = "{$method} {$path} HTTP/{$http_ver}\r\n";
     foreach ($headers as $k => $v) {
         if (is_string($k)) {
             $v = ucfirst($k) . ": {$v}";
         }
         $request .= "{$v}\r\n";
     }
     // Send the headers over
     $request .= "\r\n";
     if (!@fwrite($this->socket, $request)) {
         throw new Adapter\Exception('Error writing request to server');
     }
     //read from $body, write to socket
     $chunk = $body->read(self::CHUNK_SIZE);
     while ($chunk !== FALSE) {
         if (!@fwrite($this->socket, $chunk)) {
             throw new Adapter\Exception('Error writing request to server');
         }
         $chunk = $body->read(self::CHUNK_SIZE);
     }
     $body->closeFileHandle();
     return 'Large upload, request is not cached.';
 }
开发者ID:rmarshall-quibids,项目名称:zf2,代码行数:51,代码来源:HttpAdapterStreamingSocket.php


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