Version 1
[yaffs-website] / web / core / modules / aggregator / tests / modules / aggregator_test / src / Plugin / aggregator / fetcher / TestFetcher.php
diff --git a/web/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/fetcher/TestFetcher.php b/web/core/modules/aggregator/tests/modules/aggregator_test/src/Plugin/aggregator/fetcher/TestFetcher.php
new file mode 100644 (file)
index 0000000..02fd209
--- /dev/null
@@ -0,0 +1,32 @@
+<?php
+
+namespace Drupal\aggregator_test\Plugin\aggregator\fetcher;
+
+use Drupal\aggregator\Plugin\FetcherInterface;
+use Drupal\aggregator\Plugin\aggregator\fetcher\DefaultFetcher;
+use Drupal\aggregator\FeedInterface;
+
+/**
+ * Defines a test fetcher implementation.
+ *
+ * Uses http_client class to download the feed.
+ *
+ * @AggregatorFetcher(
+ *   id = "aggregator_test_fetcher",
+ *   title = @Translation("Test fetcher"),
+ *   description = @Translation("Dummy fetcher for testing purposes.")
+ * )
+ */
+class TestFetcher extends DefaultFetcher implements FetcherInterface {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function fetch(FeedInterface $feed) {
+    if ($feed->label() == 'Do not fetch') {
+      return FALSE;
+    }
+    return parent::fetch($feed);
+  }
+
+}