Skip to content

Commit

Permalink
introduced abstract configuration class, removed legacy code
Browse files Browse the repository at this point in the history
  • Loading branch information
tuegeb committed Mar 2, 2016
1 parent cf56f1d commit 3409c92
Show file tree
Hide file tree
Showing 6 changed files with 236 additions and 15 deletions.
1 change: 0 additions & 1 deletion FACTFinder/Adapter/Suggest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ private function createSuggestions()
$suggestQueryData['hitCount'],
$suggestQueryData['type'],
$suggestQueryData['image'],
isset($suggestQueryData['refKey']) ? $suggestQueryData['refKey'] : '',
$suggestAttributes
);
}
Expand Down
231 changes: 231 additions & 0 deletions FACTFinder/Core/AbstractConfiguration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
<?php
namespace FACTFinder\Core;

/**
* Base class for the configuration implementation.
*/
abstract class AbstractConfiguration implements ConfigurationInterface
{

public function getCustomValue($name)
{
return null;
}

public function isDebugEnabled()
{
return false;
}

public function getRequestProtocol()
{
return 'http';
}

public function getServerAddress()
{
return null;
}

public function getServerPort()
{
return '80';
}

public function getContext()
{
return null;
}

public function getChannel()
{
return null;
}

public function getLanguage()
{
return null;
}

public function isHttpAuthenticationType()
{
return false;
}

public function isSimpleAuthenticationType()
{
return false;
}

public function isAdvancedAuthenticationType()
{
return false;
}

private function retrieveType()
{
return null;
}

public function getUserName()
{
return null;
}

public function getPassword()
{
return null;
}

public function getAuthenticationPrefix()
{
return null;
}

public function getAuthenticationPostfix()
{
return null;
}

public function getClientMappings()
{
return array();
}

public function getServerMappings()
{
return array();
}

public function getIgnoredClientParameters()
{
return array();
}

public function getIgnoredServerParameters()
{
return array();
}

public function getWhitelistClientParameters()
{
return array();
}

public function getWhitelistServerParameters()
{
return array(
'/^filter.*/' => 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';
}
}

2 changes: 1 addition & 1 deletion FACTFinder/Core/ManualConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 4 additions & 1 deletion FACTFinder/Core/XmlConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion FACTFinder/Data/FilterGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 0 additions & 11 deletions FACTFinder/Data/SuggestQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class SuggestQuery extends Item
private $hitCount;
private $type;
private $imageUrl;
private $refKey;
private $attributes;

/**
Expand All @@ -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(
Expand All @@ -29,15 +27,13 @@ public function __construct(
$hitCount = 0,
$type = '',
$imageUrl = '',
$refKey = '',
array $attributes = array()
) {
// Suggestions are never pre-selected.
parent::__construct($query, $url, false);
$this->hitCount = (int)$hitCount;
$this->type = (string)$type;
$this->imageUrl = (string)$imageUrl;
$this->refKey = (string)$refKey;
$this->attributes = $attributes;
}

Expand All @@ -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
*/
Expand Down

0 comments on commit 3409c92

Please sign in to comment.