Elastica\Request::getPath PHP Method

getPath() public method

Return request path.
public getPath ( ) : string
return string Request path
    public function getPath()
    {
        return $this->getParam('path');
    }

Usage Example

コード例 #1
0
ファイル: Memcache.php プロジェクト: bretanac93/event
 /**
  * Makes calls to the elasticsearch server.
  *
  * @param \Elastica\Request $request
  * @param array             $params  Host, Port, ...
  *
  * @throws \Elastica\Exception\ResponseException
  * @throws \Elastica\Exception\InvalidException
  *
  * @return \Elastica\Response Response object
  */
 public function exec(Request $request, array $params)
 {
     $memcache = new \Memcache();
     $memcache->connect($this->getConnection()->getHost(), $this->getConnection()->getPort());
     $data = $request->getData();
     $content = '';
     if (!empty($data) || '0' === $data) {
         if (is_array($data)) {
             $content = JSON::stringify($data);
         } else {
             $content = $data;
         }
         // Escaping of / not necessary. Causes problems in base64 encoding of files
         $content = str_replace('\\/', '/', $content);
     }
     $responseString = '';
     $start = microtime(true);
     switch ($request->getMethod()) {
         case Request::POST:
         case Request::PUT:
             $key = $request->getPath();
             $this->_checkKeyLength($key);
             $memcache->set($key, $content);
             break;
         case Request::GET:
             $key = $request->getPath() . '?source=' . $content;
             $this->_checkKeyLength($key);
             $responseString = $memcache->get($key);
             break;
         case Request::DELETE:
             $key = $request->getPath() . '?source=' . $content;
             $this->_checkKeyLength($key);
             $responseString = $memcache->delete($key);
             break;
         default:
         case Request::HEAD:
             throw new InvalidException('Method ' . $request->getMethod() . ' is not supported in memcache transport');
     }
     $end = microtime(true);
     $response = new Response($responseString);
     if (\Elastica\Util::debugEnabled()) {
         $response->setQueryTime($end - $start);
     }
     if ($response->hasError()) {
         throw new ResponseException($request, $response);
     }
     if ($response->hasFailedShards()) {
         throw new PartialShardFailureException($request, $response);
     }
     return $response;
 }
All Usage Examples Of Elastica\Request::getPath