2c2 < index bdf142e..37aefb4 100644 --- > index 6706f29..0978bd3 100644 5c5 < @@ -108,133 +108,6 @@ function aggregator_feed_add() { --- > @@ -110,143 +110,6 @@ function aggregator_feed_add() { 87,89c87,91 < - $response = drupal_http_request($form_state['values']['remote']); < - if (!isset($response->error)) { < - $data = $response->data; --- > - try { > - $response = Drupal::httpClient() > - ->get($form_state['values']['remote']) > - ->send(); > - $data = $response->getBody(TRUE); 91,92c93,102 < - else { < - watchdog('aggregator', 'HTTP request to @url failed with error: @error', array('@url' => $form_state['values']['remote'], '@error' => $response->error)); --- > - catch (BadResponseException $e) { > - $response = $e->getResponse(); > - watchdog('aggregator', 'Failed to download OPML file due to "%error".', array('%error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase()), WATCHDOG_WARNING); > - drupal_set_message(t('Failed to download OPML file due to "%error".', array('%error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase()))); > - return; > - } > - catch (RequestException $e) { > - watchdog('aggregator', 'Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()), WATCHDOG_WARNING); > - drupal_set_message(t('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()))); > - return; 173c183 < index 0000000..67d7a49 --- > index 0000000..f8e0100 176c186 < @@ -0,0 +1,174 @@ --- > @@ -0,0 +1,198 @@ 187a198 > +use Drupal\Core\Entity\EntityManager; 189a201,202 > +use Guzzle\Http\Exception\RequestException; > +use Guzzle\Http\Exception\BadResponseException; 196a210,216 > + * Stores the Entity manager. > + * > + * @var \Drupal\Core\Entity\EntityManager > + */ > + protected $entityManager; > + > + /** 209c229,232 < + return new static($container->get('database')); --- > + return new static( > + $container->get('database'), > + $container->get('plugin.manager.entity') > + ); 216a240,241 > + * @param \Drupal\Core\Entity\EntityManager $entity_manager > + * The Entity manager. 218c243 < + public function __construct(Connection $database) { --- > + public function __construct(Connection $database, EntityManager $entity_manager) { 219a245 > + $this->entityManager = $entity_manager; 288c314 < + } --- > + } 301,303c327,337 < + $response = drupal_http_request($form_state['values']['remote']); < + if (!isset($response->error)) { < + $data = $response->data; --- > + try { > + $response = Drupal::httpClient() > + ->get($form_state['values']['remote']) > + ->send(); > + $data = $response->getBody(TRUE); > + } > + catch (BadResponseException $e) { > + $response = $e->getResponse(); > + watchdog('aggregator', 'Failed to download OPML file due to "%error".', array('%error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase()), WATCHDOG_WARNING); > + drupal_set_message(t('Failed to download OPML file due to "%error".', array('%error' => $response->getStatusCode() . ' ' . $response->getReasonPhrase()))); > + return; 305,306c339,342 < + else { < + watchdog('aggregator', 'HTTP request to @url failed with error: @error', array('@url' => $form_state['values']['remote'], '@error' => $response->error)); --- > + catch (RequestException $e) { > + watchdog('aggregator', 'Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()), WATCHDOG_WARNING); > + drupal_set_message(t('Failed to download OPML file due to "%error".', array('%error' => $e->getMessage()))); > + return; 336,343c372,377 < + $new_feed = drupal_container()->get('plugin.manager.entity') < + ->getStorageController('aggregator_feed') < + ->create(array( < + 'title' => $feed['title'], < + 'url' => $feed['url'], < + 'refresh' => $form_state['values']['refresh'], < + 'block' => $form_state['values']['block'], < + )); --- > + $new_feed = $this->entityManager->getStorageController('aggregator_feed')->create(array( > + 'title' => $feed['title'], > + 'url' => $feed['url'], > + 'refresh' => $form_state['values']['refresh'], > + 'block' => $form_state['values']['block'], > + ));