FIX: Updated namespace refs for GuzzleHttp (from Guzzle\Http)

This commit is contained in:
Russell Michell 2017-12-22 14:34:40 +13:00
parent d09a5aa97c
commit 912c457c7d
2 changed files with 9 additions and 10 deletions

View File

@ -3,8 +3,7 @@
namespace SilverStripe\TextExtraction\Extractor; namespace SilverStripe\TextExtraction\Extractor;
use SilverStripe\TextExtraction\Extractor\FileTextExtractor, use SilverStripe\TextExtraction\Extractor\FileTextExtractor,
Guzzle\Http\Client, GuzzleHttp\Client,
\InvalidArgumentException,
Psr\Log\LoggerInterface; Psr\Log\LoggerInterface;
/** /**
@ -36,19 +35,19 @@ class SolrCellTextExtractor extends FileTextExtractor
/** /**
* *
* @var Guzzle\Http\Client * @var GuzzleHttp\Client
*/ */
protected $httpClient; protected $httpClient;
/** /**
* *
* @return Guzzle\Http\Client * @return GuzzleHttp\Client
* @throws InvalidArgumentException * @throws InvalidArgumentException
*/ */
public function getHttpClient() public function getHttpClient()
{ {
if (!$this->config()->get('base_url')) { if (!$this->config()->get('base_url')) {
throw new InvalidArgumentException('SolrCellTextExtractor.base_url not specified'); throw new \InvalidArgumentException('SolrCellTextExtractor.base_url not specified');
} }
if (!$this->httpClient) { if (!$this->httpClient) {
$this->httpClient = new Client($this->config()->get('base_url')); $this->httpClient = new Client($this->config()->get('base_url'));
@ -59,7 +58,7 @@ class SolrCellTextExtractor extends FileTextExtractor
/** /**
* *
* @param Guzzle\Http\Client $client * @param GuzzleHttp\Client $client
* @return void * @return void
*/ */
public function setHttpClient($client) public function setHttpClient($client)
@ -125,7 +124,7 @@ class SolrCellTextExtractor extends FileTextExtractor
->addPostFields(array('extractOnly' => 'true', 'extractFormat' => 'text')) ->addPostFields(array('extractOnly' => 'true', 'extractFormat' => 'text'))
->addPostFiles(array('myfile' => $path)); ->addPostFiles(array('myfile' => $path));
$response = $request->send(); $response = $request->send();
} catch (InvalidArgumentException $e) { } catch (\InvalidArgumentException $e) {
$msg = sprintf( $msg = sprintf(
'Error extracting text from "%s" (message: %s)', 'Error extracting text from "%s" (message: %s)',
$path, $path,
@ -134,7 +133,7 @@ class SolrCellTextExtractor extends FileTextExtractor
Injector::inst()->get(LoggerInterface::class)->notice($msg); Injector::inst()->get(LoggerInterface::class)->notice($msg);
return null; return null;
} catch (Guzzle\Http\Exception\ServerErrorResponseException $e) { } catch (\Exception $e) {
// Catch other errors that Tika can throw vai Guzzle but are not caught and break Solr search query in some cases. // Catch other errors that Tika can throw vai Guzzle but are not caught and break Solr search query in some cases.
$msg = sprintf( $msg = sprintf(
'Tika server error attempting to extract from "%s" (message: %s)', 'Tika server error attempting to extract from "%s" (message: %s)',

View File

@ -2,8 +2,8 @@
namespace SilverStripe\TextExtraction\Rest; namespace SilverStripe\TextExtraction\Rest;
use Guzzle\Http\Client, use GuzzleHttp\Client,
Guzzle\Http\Exception\RequestException, GuzzleHttp\Exception\RequestException,
SilverStripe\Core\Environment, SilverStripe\Core\Environment,
Psr\Log\LoggerInterface, Psr\Log\LoggerInterface,
SilverStripe\Core\Injector\Injector; SilverStripe\Core\Injector\Injector;