From 5435578cd2d0fe91321e55ff754471a283124261 Mon Sep 17 00:00:00 2001 From: Tobias Nitsche Date: Tue, 31 Jan 2017 09:24:07 +0100 Subject: [PATCH] Guzzle Client injected --- Resources/config/methods.xml | 7 +++++++ Translate/Method.php | 11 ++++++----- Translate/Method/Translator.php | 12 +++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Resources/config/methods.xml b/Resources/config/methods.xml index 5e18893..2c58e69 100644 --- a/Resources/config/methods.xml +++ b/Resources/config/methods.xml @@ -21,19 +21,26 @@ %eko_google_translate.api_key% + %eko_google_translate.api_key% + %eko_google_translate.api_key% + + + + + diff --git a/Translate/Method.php b/Translate/Method.php index ff22a7a..b049864 100644 --- a/Translate/Method.php +++ b/Translate/Method.php @@ -54,15 +54,16 @@ class Method protected $counter = 1; /** - * Constructor. + * Method constructor. * - * @param string $apiKey API key retrieved from configuration - * @param Stopwatch $stopwatch Symfony profiler Stopwatch service + * @param string $apiKey API key retrieved from configuration + * @param GuzzleClient $client + * @param Stopwatch $stopwatch Symfony profiler Stopwatch service */ - public function __construct($apiKey, Stopwatch $stopwatch = null) + public function __construct($apiKey, GuzzleClient $client, Stopwatch $stopwatch = null) { $this->apiKey = $apiKey; - $this->client = new GuzzleClient(); + $this->client = $client; $this->stopwatch = $stopwatch; } diff --git a/Translate/Method/Translator.php b/Translate/Method/Translator.php index 60fcfb0..dc6f62d 100644 --- a/Translate/Method/Translator.php +++ b/Translate/Method/Translator.php @@ -12,6 +12,7 @@ use Eko\GoogleTranslateBundle\Translate\Method; use Eko\GoogleTranslateBundle\Translate\MethodInterface; +use GuzzleHttp\Client as GuzzleClient; use Symfony\Component\Stopwatch\Stopwatch; /** @@ -49,15 +50,16 @@ class Translator extends Method implements MethodInterface /** * Constructor. * - * @param string $apiKey Google Translate API key - * @param Detector $detector A Detector service - * @param Stopwatch $stopwatch Symfony profiler stopwatch service + * @param string $apiKey Google Translate API key + * @param GuzzleClient $client + * @param Detector $detector A Detector service + * @param Stopwatch $stopwatch Symfony profiler stopwatch service */ - public function __construct($apiKey, Detector $detector, Stopwatch $stopwatch = null) + public function __construct($apiKey, GuzzleClient $client, Detector $detector, Stopwatch $stopwatch = null) { $this->detector = $detector; - return parent::__construct($apiKey, $stopwatch); + return parent::__construct($apiKey, $client, $stopwatch); } /**