本文整理汇总了PHP中FACTFinder\Loader::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Loader::getInstance方法的具体用法?PHP Loader::getInstance怎么用?PHP Loader::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FACTFinder\Loader
的用法示例。
在下文中一共展示了Loader::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($loggerClass, \FACTFinder\Core\ConfigurationInterface $configuration, \FACTFinder\Core\Client\RequestParser $requestParser, \FACTFinder\Core\AbstractEncodingConverter $encodingConverter = null)
{
$this->log = $loggerClass::getLogger(__CLASS__);
$this->parametersConverter = FF::getInstance('Core\\ParametersConverter', $loggerClass, $configuration);
$this->requestParser = $requestParser;
$this->encodingConverter = $encodingConverter;
}
示例2: createSuggestions
private function createSuggestions()
{
$suggestions = array();
$this->useJsonResponseContentProcessor();
if (isset($this->parameters['format'])) {
$oldFormat = $this->parameters['format'];
}
$this->parameters['format'] = 'json';
$suggestData = $this->getResponseContent();
if (!empty($suggestData)) {
foreach ($suggestData as $suggestQueryData) {
$suggestLink = $this->convertServerQueryToClientUrl($suggestQueryData['searchParams']);
if (isset($suggestQueryData['attributes']) && is_array($suggestQueryData['attributes'])) {
$suggestAttributes = $suggestQueryData['attributes'];
} else {
$suggestAttributes = array();
}
$suggestions[] = FF::getInstance('Data\\SuggestQuery', $suggestQueryData['name'], $suggestLink, $suggestQueryData['hitCount'], $suggestQueryData['type'], $suggestQueryData['image'], $suggestQueryData['refKey'], $suggestAttributes);
}
}
if (isset($oldFormat)) {
$this->parameters['format'] = $oldFormat;
}
return $suggestions;
}
示例3: testConstructionFromParameters
public function testConstructionFromParameters()
{
$parameters = FF::getInstance('Util\\Parameters');
$parameters['query'] = 'bmx';
$parameters['seoPath'] = '/bmx-bike/q';
$parameters['channel'] = 'de';
$parameters['advisorStatus'] = '2-_0_0';
$parameters['productsPerPage'] = 12;
$parameters['filterBrand'] = 'KHE';
$parameters['filterColor'] = 'green';
$parameters['sortPrice'] = 'asc';
$parameters['catalog'] = 'true';
$parameters['followSearch'] = '9832';
$searchParameters = FF::getInstance('Data\\SearchParameters', $parameters);
$this->assertEquals('bmx', $searchParameters->getQuery());
$this->assertEquals('/bmx-bike/q', $searchParameters->getSeoPath());
$this->assertEquals('de', $searchParameters->getChannel());
$this->assertEquals('2-_0_0', $searchParameters->getAdvisorStatus());
$this->assertEquals(12, $searchParameters->getProductsPerPage());
$this->assertEquals(1, $searchParameters->getCurrentPage());
$this->assertEquals(9832, $searchParameters->getFollowSearch());
$this->assertEquals(array('Brand' => 'KHE', 'Color' => 'green'), $searchParameters->getFilters());
$this->assertEquals(array('Price' => 'asc'), $searchParameters->getSortings());
$this->assertTrue($searchParameters->isNavigationEnabled());
}
示例4: setUp
public function setUp()
{
parent::setUp();
$this->requestParser = FF::getInstance('Core\\Client\\RequestParser', self::$dic['loggerClass'], self::$dic['configuration'], self::$dic['encodingConverter']);
$loggerClass = self::$dic['loggerClass'];
$this->log = $loggerClass::getLogger(__CLASS__);
}
示例5: setUp
public function setUp()
{
parent::setUp();
$loggerClass = self::$dic['loggerClass'];
$this->log = $loggerClass::getLogger(__CLASS__);
$this->adapter = FF::getInstance('Adapter\\Recommendation', self::$dic['loggerClass'], self::$dic['configuration'], self::$dic['request'], self::$dic['clientUrlBuilder']);
}
示例6: loadResponse
public function loadResponse($id)
{
if (!isset($this->connectionData[$id])) {
throw new \InvalidArgumentException('Tried to get response for invalid ID $id.');
}
$connectionData = $this->connectionData[$id];
$action = $connectionData->getAction();
if (empty($action)) {
$this->log->error('Request type missing.');
$connectionData->setNullResponse();
return;
}
$fileNamePrefix = $this->getFileNamePrefix($connectionData);
$fileExtension = $this->getFileExtension($connectionData);
$queryString = $this->getQueryString($connectionData);
$fileName = $this->getFileName($fileNamePrefix, md5($queryString), $fileExtension);
if (!$this->hasFileNameChanged($id, $fileName)) {
return;
}
$this->log->info("Trying to load file: {$fileName}");
$fileContent = null;
if (!($fileContent = @file_get_contents($fileName))) {
throw new \Exception('File "' . $fileName . ' (original: ' . $fileNamePrefix . $queryString . $fileExtension . '" not found');
}
$response = FF::getInstance('Core\\Server\\Response', $fileContent, 200, 0, '');
$connectionData->setResponse($response, $fileName);
}
示例7: convert
/**
* Converts data from $inCharset to $outCharset.
* @param mixed $data If a string is given, it's encoding will be converted.
* If an associative array is given, keys and values will be
* converted recursively. All other data types will be returned
* unchanged.
* @return mixed
*/
protected function convert($inCharset, $outCharset, $data)
{
if ($data instanceof Parameters) {
if (count($data->getArray()) == 1 && current(array_keys($data->getArray())) == '') {
$result = $data->getArray();
} else {
$result = FF::getInstance('Util\\Parameters', $this->convert($inCharset, $outCharset, $data->getArray()));
}
} else {
if (is_array($data)) {
$result = array();
foreach ($data as $k => $v) {
$k = $this->convert($inCharset, $outCharset, $k);
$result[$k] = $this->convert($inCharset, $outCharset, $v);
}
} else {
if (is_string($data)) {
$result = $this->convertString($inCharset, $outCharset, $data);
} else {
$result = $data;
}
}
}
return $result;
}
示例8: testServerToClientConversion
public function testServerToClientConversion()
{
$serverParameters = FF::getInstance('Util\\Parameters', array('query' => 'test', 'username' => 'admin', 'format' => 'xml', 'xml' => 'true', 'timestamp' => '123456789', 'password' => 'test', 'channel' => 'de', 'productsPerPage' => '12'));
$expectedClientParameters = array('keywords' => 'test', 'productsPerPage' => '12');
$actualClientParameters = $this->parametersConverter->convertServerToClientParameters($serverParameters);
$this->assertEquals($expectedClientParameters, $actualClientParameters->getArray());
}
示例9: setUpBeforeClass
public static function setUpBeforeClass()
{
$logClass = FF::getClassName('Util\\Log4PhpLogger');
$logClass::configure(RESOURCES_DIR . DS . 'log4php.xml');
// Set up dependency injection container (Pimple)
self::$dic = FF::getInstance('Util\\Pimple');
self::$dic['loggerClass'] = $logClass;
if (strpos(static::class, 'ArrayConfiguration')) {
self::$dic['configuration'] = function ($c) {
$config = (include RESOURCES_DIR . DS . 'config.php');
return FF::getInstance('Core\\ArrayConfiguration', $config, 'test');
};
} else {
self::$dic['configuration'] = function ($c) {
return FF::getInstance('Core\\XmlConfiguration', RESOURCES_DIR . DS . 'config.xml', 'test');
};
}
// $this cannot be passed into closures before PHP 5.4
//$that = $this;
self::$dic['encodingConverter'] = function ($c) {
if (extension_loaded('iconv')) {
$type = 'Core\\IConvEncodingConverter';
} else {
if (function_exists('utf8_encode') && function_exists('utf8_decode')) {
$type = 'Core\\Utf8EncodingConverter';
} else {
return;
}
}
//TODO: Skip test if no conversion method is available.
// $that->markTestSkipped('No encoding conversion available.');
return FF::getInstance($type, $c['loggerClass'], $c['configuration']);
};
self::$dic['serverUrlBuilder'] = function ($c) {
return FF::getInstance('Core\\Server\\UrlBuilder', $c['loggerClass'], $c['configuration']);
};
self::$dic['clientUrlBuilder'] = function ($c) {
return FF::getInstance('Core\\Client\\UrlBuilder', $c['loggerClass'], $c['configuration'], $c['requestParser'], $c['encodingConverter']);
};
self::$dic['curlStub'] = function ($c) {
return FF::getInstance('Util\\CurlStub');
};
self::$dic['dataProvider'] = function ($c) {
$dataProvider = FF::getInstance('Core\\Server\\FileSystemDataProvider', $c['loggerClass'], $c['configuration']);
$dataProvider->setFileLocation(RESOURCES_DIR . DS . 'responses');
return $dataProvider;
};
self::$dic['requestFactory'] = function ($c) {
$requestFactory = FF::getInstance('Core\\Server\\FileSystemRequestFactory', $c['loggerClass'], $c['configuration'], $c['requestParser']->getRequestParameters());
$requestFactory->setFileLocation(RESOURCES_DIR . DS . 'responses');
return $requestFactory;
};
self::$dic['request'] = self::$dic->factory(function ($c) {
return $c['requestFactory']->getRequest();
});
self::$dic['requestParser'] = function ($c) {
return FF::getInstance('Core\\Client\\RequestParser', $c['loggerClass'], $c['configuration'], $c['encodingConverter']);
};
}
示例10: testResponse
public function testResponse()
{
$response = FF::getInstance('Core\\Server\\NullResponse');
$this->assertEquals('', $response->getContent());
$this->assertEquals(0, $response->getHttpCode());
$this->assertEquals(0, $response->getConnectionErrorCode());
$this->assertEquals('', $response->getConnectionError());
}
示例11: testResponse
public function testResponse()
{
$response = FF::getInstance('Core\\Server\\Response', 'response content', 200, CURLE_OK, 'CURLE_OK');
$this->assertEquals('response content', $response->getContent());
$this->assertEquals(200, $response->getHttpCode());
$this->assertEquals(CURLE_OK, $response->getConnectionErrorCode());
$this->assertEquals('CURLE_OK', $response->getConnectionError());
}
示例12: setUp
public function setUp()
{
parent::setUp();
$this->factory = FF::getInstance('Core\\Server\\FileSystemRequestFactory', self::$dic['loggerClass'], self::$dic['configuration'], FF::getInstance('Util\\Parameters'));
$loggerClass = self::$dic['loggerClass'];
$this->log = $loggerClass::getLogger(__CLASS__);
$this->configuration = self::$dic['configuration'];
}
示例13: setUp
public function setUp()
{
parent::setUp();
// For the request parser to retrieve
$_SERVER['REQUEST_URI'] = '/index.php';
$loggerClass = self::$dic['loggerClass'];
$this->log = $loggerClass::getLogger(__CLASS__);
$this->adapter = FF::getInstance('Adapter\\TagCloud', self::$dic['loggerClass'], self::$dic['configuration'], self::$dic['request'], self::$dic['clientUrlBuilder']);
}
示例14: setUp
public function setUp()
{
parent::setUp();
$this->urlBuilder = FF::getInstance('Core\\Server\\UrlBuilder', self::$dic['loggerClass'], self::$dic['configuration']);
$loggerClass = self::$dic['loggerClass'];
$this->log = $loggerClass::getLogger(__CLASS__);
$this->configuration = self::$dic['configuration'];
$this->parameters = FF::getInstance('Util\\Parameters');
}
示例15: setUp
public function setUp()
{
parent::setUp();
$this->curlStub = self::$dic['curlStub'];
$this->factory = FF::getInstance('Core\\Server\\MultiCurlRequestFactory', self::$dic['loggerClass'], self::$dic['configuration'], FF::getInstance('Util\\Parameters', array('query' => 'bmx')), self::$dic['curlStub']);
$loggerClass = self::$dic['loggerClass'];
$this->log = $loggerClass::getLogger(__CLASS__);
$this->configuration = self::$dic['configuration'];
}