Exemplo n.º 1
0
 public function testRqlEncode()
 {
     $this->rqlString = "and(and(eq(q,null()),ne(q,null()),le(q,r),ge(q,u)),or(lt(q,t),gt(q,y),in(q,(a,s,d,f,g))))";
     $this->rqlString .= "&limit(20,30)";
     $this->rqlString .= "&sort(-q,+w,+e)";
     $this->rqlString .= "&select(q,max(q),min(q),count(q))";
     $rqlString = RqlParser::rqlEncode($this->queryObject);
     $this->assertEquals($rqlString, $this->rqlString);
 }
Exemplo n.º 2
0
 protected function postQuery(&$result, Query $query)
 {
     if ($query->getQuery()) {
         if (count($result) === 0) {
             $queryStr = urldecode(RqlParser::rqlEncode($query));
             $pattern = '/^and\\(eq\\(tableName\\,([a-zA-Z0-9_]+)\\)\\,eq\\(name\\,_default\\)\\)/';
             $match = [];
             if (preg_match($pattern, $queryStr, $match)) {
                 $requestName = isset($match[1]) ? $match[1] : "";
                 $configuration = $this->configureGeneratorFactory->__invoke($requestName)->getConfiguration();
                 $res = ['table_name' => $requestName, 'name' => '_default', 'preference' => json_encode($configuration)];
                 foreach ($res as $key => $item) {
                     $result[0][$key] = $item;
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 /**
  *
  * @param string  'GET' 'HEAD' 'POST' 'PUT' 'DELETE';
  * @param Query $query
  * @param int|string $id
  * @param bool see $ifMatch $rewriteIfExist and $createIfAbsent in {@see DataStoreAbstract}
  * @return Client
  */
 protected function initHttpClient($method, Query $query = null, $id = null, $ifMatch = false)
 {
     $url = !$id ? $this->url : $this->url . '/' . $this->encodeString($id);
     if (isset($query)) {
         $rqlString = RqlParser::rqlEncode($query);
         $url = $url . '?' . $rqlString;
     }
     $httpClient = new Client($url, $this->options);
     $headers['Content-Type'] = 'application/json';
     $headers['Accept'] = 'application/json';
     if ($ifMatch) {
         $headers['If-Match'] = '*';
     }
     $httpClient->setHeaders($headers);
     if (isset($this->login) && isset($this->password)) {
         $httpClient->setAuth($this->login, $this->password);
     }
     $httpClient->setMethod($method);
     return $httpClient;
 }