diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php index f8e0100..8de45eb 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php @@ -14,6 +14,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; use Guzzle\Http\Exception\RequestException; use Guzzle\Http\Exception\BadResponseException; +use Guzzle\Http\Client; /** * Imports feeds from OPML. @@ -21,18 +22,25 @@ class OpmlFeedAdd implements ControllerInterface, FormInterface { /** + * Database service object. + * + * @var \Drupal\Core\Database\Connection + */ + protected $database; + + /** * Stores the Entity manager. * * @var \Drupal\Core\Entity\EntityManager */ protected $entityManager; - /** - * Database service object. + /** + * Register the Guzzle HTTP client. * - * @var \Drupal\Core\Database\Connection + * @var \Guzzle\Http\Client */ - protected $database; + protected $httpClient; /** * Injects database service. @@ -42,7 +50,8 @@ class OpmlFeedAdd implements ControllerInterface, FormInterface { public static function create(ContainerInterface $container) { return new static( $container->get('database'), - $container->get('plugin.manager.entity') + $container->get('plugin.manager.entity'), + $container->get('http_default_client') ); } @@ -53,10 +62,13 @@ public static function create(ContainerInterface $container) { * The database object. * @param \Drupal\Core\Entity\EntityManager $entity_manager * The Entity manager. + * @param \Guzzle\Http\Client + * The Guzzle HTTP client. */ - public function __construct(Connection $database, EntityManager $entity_manager) { + public function __construct(Connection $database, EntityManager $entity_manager, Client $http_client) { $this->database = $database; $this->entityManager = $entity_manager; + $this->httpClient = $http_client; } /** @@ -139,9 +151,7 @@ public function submitForm(array &$form, array &$form_state) { } else { try { - $response = Drupal::httpClient() - ->get($form_state['values']['remote']) - ->send(); + $response = $this->httpClient()->get($form_state['values']['remote'])->send(); $data = $response->getBody(TRUE); } catch (BadResponseException $e) {