From def92088b29633df5e21f4411fdb034d095e071d Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Thu, 27 Aug 2015 13:27:22 +0200 Subject: [PATCH] Remove the FilterController --- application/controllers/FilterController.php | 92 -------------------- 1 file changed, 92 deletions(-) delete mode 100644 application/controllers/FilterController.php diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php deleted file mode 100644 index 461977c7a..000000000 --- a/application/controllers/FilterController.php +++ /dev/null @@ -1,92 +0,0 @@ -registry = new Filter(); - $query = $this->getRequest()->getParam('query', ''); - $target = $this->getRequest()->getParam('filter_domain', ''); - - if ($this->getRequest()->getHeader('accept') == 'application/json') { - $this->getResponse()->setHeader('Content-Type', 'application/json'); - $this->setupQueries( - $target, - $this->getParam('filter_module', '') - ); - $this->_helper->json($this->parse($query, $target)); - } else { - $this->setupQueries( - $target, - $this->getParam('filter_module') - ); - $urlTarget = $this->parse($query, $target); - $this->redirect($urlTarget['urlParam']); - } - - - } - - /** - * Set up the query handler for the given domain and module - * - * @param string $domain The domain to use - * @param string $module The module to use - */ - private function setupQueries($domain, $module = 'default') - { - $class = '\\Icinga\\Module\\' . ucfirst($module) . '\\Filter\\Registry'; - $factory = strtolower($domain) . 'Filter'; - $this->moduleRegistry = $class; - $this->registry->addDomain($class::$factory()); - } - - /** - * Parse the given query text and returns the json as expected by the semantic search box - * - * @param String $text The query to parse - * @return array The result structure to be returned in json format - */ - private function parse($text, $target) - { - try { - - $queryTree = $this->registry->createQueryTreeForFilter($text); - $registry = $this->moduleRegistry; - return array( - 'state' => 'success', - 'proposals' => $this->registry->getProposalsForQuery($text), - 'urlParam' => $registry::getUrlForTarget($target, $queryTree), - 'valid' => count($this->registry->getIgnoredQueryParts()) === 0 - ); - } catch (\Exception $exc) { - Logger::error($exc); - $this->getResponse()->setHttpResponseCode(500); - return array( - 'state' => 'error', - 'message' => 'Search service is currently not available' - ); - } - } -}