/** * Support method for initSearch() -- handle advanced settings. Advanced * searches have numeric subscripts on the lookfor and type parameters -- * this is how they are distinguished from basic searches. * * @param \Zend\StdLib\Parameters $request Parameter object representing user * request. * * @return void */ protected function initAdvancedSearch($request) { $this->query = QueryAdapter::fromRequest($request, $this->getOptions()->getDefaultHandler()); $this->searchType = $this->query instanceof Query ? 'basic' : 'advanced'; // If we ended up with a basic search, set the default handler if necessary: if ($this->searchType == 'basic' && $this->query->getHandler() === null) { $this->query->setHandler($this->getOptions()->getDefaultHandler()); } }
/** * Support method for initSearch() -- handle advanced settings. Advanced * searches have numeric subscripts on the lookfor and type parameters -- * this is how they are distinguished from basic searches. * * @param \Zend\StdLib\Parameters $request Parameter object representing user * request. * * @return void */ protected function initAdvancedSearch($request) { $this->query = QueryAdapter::fromRequest($request, $this->getOptions()->getDefaultHandler()); $this->searchType = $this->query instanceof Query ? 'basic' : 'advanced'; // If we ended up with a basic search, it's probably the result of // submitting an empty form, and more processing may be needed: if ($this->searchType == 'basic') { // Set a default handler if necessary: if ($this->query->getHandler() === null) { $this->query->setHandler($this->getOptions()->getDefaultHandler()); } // If the user submitted the advanced search form, we want to treat // the search as advanced even if it evaluated to a basic search. if ($request->offsetExists('lookfor0')) { $this->convertToAdvancedSearch(); } } }
/** * Test building an advanced query from an empty request. * * @return void */ public function testEmptyRequest() { $req = new \Zend\Stdlib\Parameters([]); $this->assertEquals(new Query(), QueryAdapter::fromRequest($req, 'AllFields')); }