summaryrefslogtreecommitdiffstats
path: root/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php')
-rw-r--r--core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
index 6c6793a..3df80a3 100644
--- a/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
+++ b/core/modules/aggregator/src/Plugin/aggregator/fetcher/DefaultFetcher.php
@@ -6,6 +6,7 @@ use Drupal\aggregator\Plugin\FetcherInterface;
use Drupal\aggregator\FeedInterface;
use Drupal\Component\Datetime\DateTimePlus;
use Drupal\Core\Http\ClientFactory;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\Request;
@@ -43,16 +44,26 @@ class DefaultFetcher implements FetcherInterface, ContainerFactoryPluginInterfac
protected $logger;
/**
+ * The messenger.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
+ /**
* Constructs a DefaultFetcher object.
*
* @param \Drupal\Core\Http\ClientFactory $http_client_factory
* A Guzzle client object.
* @param \Psr\Log\LoggerInterface $logger
* A logger instance.
+ * @param \Drupal\Core\Messenger\MessengerInterface $messenger
+ * The messenger.
*/
- public function __construct(ClientFactory $http_client_factory, LoggerInterface $logger) {
+ public function __construct(ClientFactory $http_client_factory, LoggerInterface $logger, MessengerInterface $messenger) {
$this->httpClientFactory = $http_client_factory;
$this->logger = $logger;
+ $this->messenger = $messenger;
}
/**
@@ -61,7 +72,8 @@ class DefaultFetcher implements FetcherInterface, ContainerFactoryPluginInterfac
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$container->get('http_client_factory'),
- $container->get('logger.factory')->get('aggregator')
+ $container->get('logger.factory')->get('aggregator'),
+ $container->get('messenger')
);
}
@@ -115,7 +127,7 @@ class DefaultFetcher implements FetcherInterface, ContainerFactoryPluginInterfac
}
catch (RequestException $e) {
$this->logger->warning('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]);
- drupal_set_message(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]), 'warning');
+ $this->messenger->addWarning(t('The feed from %site seems to be broken because of error "%error".', ['%site' => $feed->label(), '%error' => $e->getMessage()]));
return FALSE;
}
}