Bolt\Controller\Backend\General::omnisearch PHP Method

omnisearch() public method

Show the Omnisearch results.
public omnisearch ( Request $request ) : TemplateResponse
$request Symfony\Component\HttpFoundation\Request The Symfony Request
return Bolt\Response\TemplateResponse
    public function omnisearch(Request $request)
    {
        $query = $request->query->get('q', '');
        $records = [];
        $others = [];
        if (strlen($query) >= 3) {
            foreach ($this->app['omnisearch']->query($query, true) as $result) {
                if (isset($result['slug'])) {
                    $records[$result['slug']][] = $result;
                } elseif ($result['priority'] !== Omnisearch::OMNISEARCH_LANDINGPAGE) {
                    $others[] = $result;
                }
            }
        }
        $context = ['query' => $query, 'records' => $records, 'others' => $others];
        return $this->render('@bolt/omnisearch/omnisearch.twig', $context);
    }