searchContent() public method

Unless the query is invalid it will always return a 'result array'. It may complain in the log but it won't abort.
public searchContent ( string $q, array $contenttypes = null, array $filters = null, integer $limit = 9999, integer $offset ) : mixed
$q string Search string
$contenttypes array Contenttype names to search for: - string: Specific contenttype - null: Every searchable contenttype
$filters array Additional filters for contenttypes - key is contenttype - value is filter
$limit integer limit the number of results
$offset integer skip this number of results
return mixed false if query is invalid, an array with results if query was executed
Exemplo n.º 1
0
 public function testSearchContent()
 {
     $app = $this->getApp();
     $app['request'] = Request::create('/');
     $storage = new Storage($app);
     $result = $storage->searchContent('lorem');
     $this->assertGreaterThan(0, count($result));
     $this->assertTrue($result['query']['valid']);
     // Test invalid query fails
     $result = $storage->searchContent('x');
     $this->assertFalse($result);
     // Test filters
     $result = $storage->searchContent('lorem', ['showcases'], ['showcases' => ['title' => 'nonexistent']]);
     $this->assertTrue($result['query']['valid']);
     $this->assertEquals(0, $result['no_of_results']);
 }