From be9552daecd25adea9a68e167ba6a6a7111cf1d8 Mon Sep 17 00:00:00 2001 From: Dries Date: Wed, 15 May 2013 09:33:38 -0400 Subject: [PATCH] Issue #1969692 by dawehner: Add a dedicated annotation for aggregator Plugins. --- .../Annotation/AggregatorFetcher.php | 44 +++++++++++++++++++ .../Annotation/AggregatorParser.php | 44 +++++++++++++++++++ .../Annotation/AggregatorProcessor.php | 44 +++++++++++++++++++ .../Plugin/AggregatorPluginManager.php | 12 ++++- .../aggregator/fetcher/DefaultFetcher.php | 4 +- .../aggregator/parser/DefaultParser.php | 4 +- .../aggregator/processor/DefaultProcessor.php | 4 +- .../Plugin/aggregator/fetcher/TestFetcher.php | 4 +- .../Plugin/aggregator/parser/TestParser.php | 4 +- .../aggregator/processor/TestProcessor.php | 4 +- 10 files changed, 155 insertions(+), 13 deletions(-) create mode 100644 core/modules/aggregator/lib/Drupal/aggregator/Annotation/AggregatorFetcher.php create mode 100644 core/modules/aggregator/lib/Drupal/aggregator/Annotation/AggregatorParser.php create mode 100644 core/modules/aggregator/lib/Drupal/aggregator/Annotation/AggregatorProcessor.php diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Annotation/AggregatorFetcher.php b/core/modules/aggregator/lib/Drupal/aggregator/Annotation/AggregatorFetcher.php new file mode 100644 index 00000000000..0fbee2fe37d --- /dev/null +++ b/core/modules/aggregator/lib/Drupal/aggregator/Annotation/AggregatorFetcher.php @@ -0,0 +1,44 @@ +discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces); + $type_annotations = array( + 'fetcher' => 'Drupal\aggregator\Annotation\AggregatorFetcher', + 'parser' => 'Drupal\aggregator\Annotation\AggregatorParser', + 'processor' => 'Drupal\aggregator\Annotation\AggregatorProcessor', + ); + + $annotation_namespaces = array( + 'Drupal\aggregator\Annotation' => DRUPAL_ROOT . '/core/modules/aggregator/lib', + ); + + $this->discovery = new AnnotatedClassDiscovery("aggregator/$type", $namespaces, $annotation_namespaces, $type_annotations[$type]); $this->discovery = new CacheDecorator($this->discovery, "aggregator_$type:" . language(LANGUAGE_TYPE_INTERFACE)->langcode); $this->factory = new DefaultFactory($this->discovery); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php index e71412be3d5..e98411ecb14 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/fetcher/DefaultFetcher.php @@ -9,7 +9,7 @@ namespace Drupal\aggregator\Plugin\aggregator\fetcher; use Drupal\aggregator\Plugin\FetcherInterface; use Drupal\aggregator\Plugin\Core\Entity\Feed; -use Drupal\Component\Annotation\Plugin; +use Drupal\aggregator\Annotation\AggregatorFetcher; use Drupal\Core\Annotation\Translation; use Guzzle\Http\Exception\BadResponseException; use Guzzle\Http\Exception\RequestException; @@ -19,7 +19,7 @@ use Guzzle\Http\Exception\RequestException; * * Uses the http_default_client service to download the feed. * - * @Plugin( + * @AggregatorFetcher( * id = "aggregator", * title = @Translation("Default fetcher"), * description = @Translation("Downloads data from a URL using Drupal's HTTP request handler.") diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php index 0086baca1dc..eab6e9baf1e 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/parser/DefaultParser.php @@ -9,7 +9,7 @@ namespace Drupal\aggregator\Plugin\aggregator\parser; use Drupal\aggregator\Plugin\ParserInterface; use Drupal\aggregator\Plugin\Core\Entity\Feed; -use Drupal\Component\Annotation\Plugin; +use Drupal\aggregator\Annotation\AggregatorParser; use Drupal\Core\Annotation\Translation; /** @@ -17,7 +17,7 @@ use Drupal\Core\Annotation\Translation; * * Parses RSS, Atom and RDF feeds. * - * @Plugin( + * @AggregatorParser( * id = "aggregator", * title = @Translation("Default parser"), * description = @Translation("Default parser for RSS, Atom and RDF feeds.") diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php index 08777d18ac5..6b160ffe933 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/aggregator/processor/DefaultProcessor.php @@ -10,7 +10,7 @@ namespace Drupal\aggregator\Plugin\aggregator\processor; use Drupal\Component\Plugin\PluginBase; use Drupal\aggregator\Plugin\ProcessorInterface; use Drupal\aggregator\Plugin\Core\Entity\Feed; -use Drupal\Component\Annotation\Plugin; +use Drupal\aggregator\Annotation\AggregatorProcessor; use Drupal\Core\Annotation\Translation; use Drupal\Core\Database\Database; @@ -19,7 +19,7 @@ use Drupal\Core\Database\Database; * * Creates lightweight records from feed items. * - * @Plugin( + * @AggregatorProcessor( * id = "aggregator", * title = @Translation("Default processor"), * description = @Translation("Creates lightweight records from feed items.") diff --git a/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php b/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php index 87975b50d17..8e69f8d5a9a 100644 --- a/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php +++ b/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/fetcher/TestFetcher.php @@ -10,7 +10,7 @@ namespace Drupal\aggregator_test\Plugin\aggregator\fetcher; use Drupal\aggregator\Plugin\FetcherInterface; use Drupal\aggregator\Plugin\aggregator\fetcher\DefaultFetcher; use Drupal\aggregator\Plugin\Core\Entity\Feed; -use Drupal\Component\Annotation\Plugin; +use Drupal\aggregator\Annotation\AggregatorFetcher; use Drupal\Core\Annotation\Translation; use Guzzle\Http\Exception\BadResponseException; @@ -19,7 +19,7 @@ use Guzzle\Http\Exception\BadResponseException; * * Uses http_default_client class to download the feed. * - * @Plugin( + * @AggregatorFetcher( * id = "aggregator_test_fetcher", * title = @Translation("Test fetcher"), * description = @Translation("Dummy fetcher for testing purposes.") diff --git a/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/parser/TestParser.php b/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/parser/TestParser.php index f69876395ac..a9ab57cc8a6 100644 --- a/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/parser/TestParser.php +++ b/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/parser/TestParser.php @@ -10,7 +10,7 @@ namespace Drupal\aggregator_test\Plugin\aggregator\parser; use Drupal\aggregator\Plugin\ParserInterface; use Drupal\aggregator\Plugin\Core\Entity\Feed; use Drupal\aggregator\Plugin\aggregator\parser\DefaultParser; -use Drupal\Component\Annotation\Plugin; +use Drupal\aggregator\Annotation\AggregatorParser; use Drupal\Core\Annotation\Translation; /** @@ -18,7 +18,7 @@ use Drupal\Core\Annotation\Translation; * * Parses RSS, Atom and RDF feeds. * - * @Plugin( + * @AggregatorParser( * id = "aggregator_test_parser", * title = @Translation("Test parser"), * description = @Translation("Dummy parser for testing purposes.") diff --git a/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/processor/TestProcessor.php b/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/processor/TestProcessor.php index 3ffe2133c36..e218b8a8f9e 100644 --- a/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/processor/TestProcessor.php +++ b/core/modules/aggregator/tests/lib/Drupal/aggregator_test/Plugin/aggregator/processor/TestProcessor.php @@ -10,7 +10,7 @@ namespace Drupal\aggregator_test\Plugin\aggregator\processor; use Drupal\Component\Plugin\PluginBase; use Drupal\aggregator\Plugin\ProcessorInterface; use Drupal\aggregator\Plugin\Core\Entity\Feed; -use Drupal\Component\Annotation\Plugin; +use Drupal\aggregator\Annotation\AggregatorProcessor; use Drupal\Core\Annotation\Translation; /** @@ -18,7 +18,7 @@ use Drupal\Core\Annotation\Translation; * * Creates lightweight records from feed items. * - * @Plugin( + * @AggregatorProcessor( * id = "aggregator_test_processor", * title = @Translation("Test processor"), * description = @Translation("Test generic processor functionality.")