From 3409c921cee959e4a52cb936f1ce568b6a06a6f3 Mon Sep 17 00:00:00 2001 From: tuegeb Date: Wed, 2 Mar 2016 12:25:35 +0100 Subject: [PATCH] introduced abstract configuration class, removed legacy code --- FACTFinder/Adapter/Suggest.php | 1 - FACTFinder/Core/AbstractConfiguration.php | 231 ++++++++++++++++++++++ FACTFinder/Core/ManualConfiguration.php | 2 +- FACTFinder/Core/XmlConfiguration.php | 5 +- FACTFinder/Data/FilterGroup.php | 1 - FACTFinder/Data/SuggestQuery.php | 11 -- 6 files changed, 236 insertions(+), 15 deletions(-) create mode 100644 FACTFinder/Core/AbstractConfiguration.php diff --git a/FACTFinder/Adapter/Suggest.php b/FACTFinder/Adapter/Suggest.php index 542a826..1d63653 100644 --- a/FACTFinder/Adapter/Suggest.php +++ b/FACTFinder/Adapter/Suggest.php @@ -90,7 +90,6 @@ private function createSuggestions() $suggestQueryData['hitCount'], $suggestQueryData['type'], $suggestQueryData['image'], - isset($suggestQueryData['refKey']) ? $suggestQueryData['refKey'] : '', $suggestAttributes ); } diff --git a/FACTFinder/Core/AbstractConfiguration.php b/FACTFinder/Core/AbstractConfiguration.php new file mode 100644 index 0000000..8486588 --- /dev/null +++ b/FACTFinder/Core/AbstractConfiguration.php @@ -0,0 +1,231 @@ + true, + '/^sort.*/' => true, + '/^substringFilter.*/' => true, + 'advisorStatus' => true, + 'callback' => true, + 'catalog' => true, + 'channel' => true, + 'cookieId' => true, + 'count' => true, + 'do' => true, + 'event' => true, + 'followSearch' => true, + 'format' => true, + 'id' => true, + 'idsOnly' => true, + 'ignoreForCache' => true, + 'isArticleNumber' => true, + 'log' => true, + 'mainId' => true, + 'masterId' => true, + 'maxRecordCount' => true, + 'maxResults' => true, + 'navigation' => true, + 'noArticleNumberSearch' => true, + 'omitContextName' => true, + 'origPageSize' => true, + 'origPos' => true, + 'page' => true, + 'pageSize' => true, + 'pos' => true, + 'price' => true, + 'productNumber' => true, + 'productsPerPage' => true, + 'query' => true, + 'queryFromSuggest' => true, + 'searchField' => true, + 'sid' => true, + 'simi' => true, + 'title' => true, + 'useAsn' => true, + 'useAso' => true, + 'useCampaigns' => true, + 'useFoundWords' => true, + 'useKeywords' => true, + 'usePersonalization' => true, + 'userId' => true, + 'userInput' => true, + 'useSemanticEnhancer' => true, + 'verbose' => true, + 'wordCount' => true + ); + } + + public function getRequiredClientParameters() + { + return array(); + } + + public function getRequiredServerParameters() + { + return array(); + } + + public function getDefaultConnectTimeout() + { + return 2; + } + + public function getDefaultTimeout() + { + return 4; + } + + public function getSuggestConnectTimeout() + { + return 2; + } + + public function getSuggestTimeout() + { + return 2; + } + + public function getTrackingConnectTimeout() + { + return 2; + } + + public function getTrackingTimeout() + { + return 2; + } + + public function getImportConnectTimeout() + { + return 10; + } + + public function getImportTimeout() + { + return 360; + } + + public function getPageContentEncoding() + { + return 'UTF-8'; + } + + public function getClientUrlEncoding() + { + return 'UTF-8'; + } +} + diff --git a/FACTFinder/Core/ManualConfiguration.php b/FACTFinder/Core/ManualConfiguration.php index 9fd7007..f0b75c1 100644 --- a/FACTFinder/Core/ManualConfiguration.php +++ b/FACTFinder/Core/ManualConfiguration.php @@ -6,7 +6,7 @@ * values to be set manually through the magic __set(). Really only useful for * testing. */ -class ManualConfiguration implements ConfigurationInterface +class ManualConfiguration extends AbstractConfiguration { const HTTP_AUTHENTICATION = 'http'; const SIMPLE_AUTHENTICATION = 'simple'; diff --git a/FACTFinder/Core/XmlConfiguration.php b/FACTFinder/Core/XmlConfiguration.php index db0309e..84b1391 100644 --- a/FACTFinder/Core/XmlConfiguration.php +++ b/FACTFinder/Core/XmlConfiguration.php @@ -5,7 +5,7 @@ * Implements ConfigurationInterface by reading from an XML file. Also allows * for some values to be changed later on. */ -class XmlConfiguration implements ConfigurationInterface +class XmlConfiguration extends AbstractConfiguration { const HTTP_AUTHENTICATION = 'http'; const SIMPLE_AUTHENTICATION = 'simple'; @@ -229,6 +229,9 @@ public function getWhitelistServerParameters() $this->whitelistServerParameters = $this->retrieveWhitelistParameters( $this->configuration->parameters->server ); + if (empty($this->whitelistServerParameters)) { + $this->whitelistServerParameters = parent::getWhitelistServerParameters(); + } } return $this->whitelistServerParameters; } diff --git a/FACTFinder/Data/FilterGroup.php b/FACTFinder/Data/FilterGroup.php index e4aebc6..41425f9 100644 --- a/FACTFinder/Data/FilterGroup.php +++ b/FACTFinder/Data/FilterGroup.php @@ -45,7 +45,6 @@ class FilterGroup extends \ArrayIterator /** * @param Filter[] $filters The Filter objects to add to the group. - * @param string $refKey * @param int $foundRecordsCount Total number of records found for the * search these records are from. This can be greater than * count($records), because $records may just be the records from a diff --git a/FACTFinder/Data/SuggestQuery.php b/FACTFinder/Data/SuggestQuery.php index c92d163..cee1c5a 100755 --- a/FACTFinder/Data/SuggestQuery.php +++ b/FACTFinder/Data/SuggestQuery.php @@ -9,7 +9,6 @@ class SuggestQuery extends Item private $hitCount; private $type; private $imageUrl; - private $refKey; private $attributes; /** @@ -20,7 +19,6 @@ class SuggestQuery extends Item * @param string $type Simple string which describes where this suggest * query comes from (e.g. product name, category, log file). * @param string $imageUrl - * @param string $refKey * @param array $attributes Additional return data fields */ public function __construct( @@ -29,7 +27,6 @@ public function __construct( $hitCount = 0, $type = '', $imageUrl = '', - $refKey = '', array $attributes = array() ) { // Suggestions are never pre-selected. @@ -37,7 +34,6 @@ public function __construct( $this->hitCount = (int)$hitCount; $this->type = (string)$type; $this->imageUrl = (string)$imageUrl; - $this->refKey = (string)$refKey; $this->attributes = $attributes; } @@ -63,13 +59,6 @@ public function getImageUrl() { return $this->imageUrl; } - /** - * @return string - */ - public function getRefKey() { - return $this->refKey; - } - /** * @return array Returns the additional return data fields */