Exemple #1
0
 public function search($index, $type, array $query)
 {
     $url = static::formUrl($index, $type) . '_search';
     $response = $this->client->request('POST', $url, ['json' => $query]);
     $hits = Json::parse($response->getBody())['hits'];
     return $hits['hits'];
 }
 /**
  * @param SessionInterface $session
  * @param Response $response
  */
 private function postRequestHandle(SessionInterface $session, Response $response)
 {
     if ($this->sessionIsPersistent($config = $this->manager->getSessionConfig())) {
         $id = $session->getId();
         $key = 'session:' . $id;
         $content = $session->all();
         unset($content['_token'], $content['flash']);
         $lastSeen = time();
         $content['last_seen'] = $lastSeen;
         $session->set('last_seen', $lastSeen);
         $value = Json::dump($content);
         $this->redis->watch($key);
         $this->redis->multi();
         $this->redis->set($key, $value);
         $this->redis->expire($key, $this->getSessionLifetimeInSeconds());
         $this->redis->exec();
         $cookie = new Cookie($this->key, $id, $this->getCookieExpirationDate(), $config['path'], $config['domain'], Arr::get($config, 'secure', false));
         $response->headers->setCookie($cookie);
     }
 }
Exemple #3
0
 public function testParse()
 {
     $data = ["query" => ["match" => ["address" => "mill"]]];
     $output = Json::parse('{"query": { "match": { "address": "mill" } }}', true);
     $this->assertSame($data, $output);
 }