Пример #1
0
 /**
  * @param $resource_id
  * @param $class_id
  * @param $dmql_query
  * @param array $optional_parameters
  * @return \PHRETS\Models\Search\Results
  * @throws Exceptions\CapabilityUnavailable
  */
 public function Search($resource_id, $class_id, $dmql_query, $optional_parameters = [], $recursive = false)
 {
     $dmql_query = Search::dmql($dmql_query);
     $defaults = ['SearchType' => $resource_id, 'Class' => $class_id, 'Query' => $dmql_query, 'QueryType' => 'DMQL2', 'Count' => 1, 'Format' => 'COMPACT-DECODED', 'Limit' => 99999999, 'StandardNames' => 0];
     $parameters = array_merge($defaults, $optional_parameters);
     // if the Select parameter given is an array, format it as it needs to be
     if (array_key_exists('Select', $parameters) and is_array($parameters['Select'])) {
         $parameters['Select'] = implode(',', $parameters['Select']);
     }
     $response = $this->request('Search', ['query' => $parameters]);
     if ($recursive) {
         $parser = $this->grab('parser.search.recursive');
     } else {
         $parser = $this->grab('parser.search');
     }
     return $parser->parse($this, $response, $parameters);
 }
Пример #2
0
 /** @test **/
 public function it_doesnt_modify_when_special_characters_are_used()
 {
     $this->assertSame('*', Search::dmql('*'));
     $this->assertSame('', Search::dmql(''));
 }