Issue #1969692 by dawehner: Add a dedicated annotation for aggregator Plugins.
parent
58bbff9d49
commit
be9552daec
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator\Annotation\AggregatorFetcher.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
||||
/**
|
||||
* Defines a Plugin annotation object for aggregator fetcher plugins.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class AggregatorFetcher extends Plugin {
|
||||
|
||||
/**
|
||||
* The plugin ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* The title of the plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Annotation\Translation
|
||||
*
|
||||
* @ingroup plugin_translatable
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* The description of the plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Annotation\Translation
|
||||
*
|
||||
* @ingroup plugin_translatable
|
||||
*/
|
||||
public $description;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator\Annotation\AggregatorParser.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
||||
/**
|
||||
* Defines a Plugin annotation object for aggregator parser plugins.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class AggregatorParser extends Plugin {
|
||||
|
||||
/**
|
||||
* The plugin ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* The title of the plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Annotation\Translation
|
||||
*
|
||||
* @ingroup plugin_translatable
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* The description of the plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Annotation\Translation
|
||||
*
|
||||
* @ingroup plugin_translatable
|
||||
*/
|
||||
public $description;
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator\Annotation\AggregatorProcessor.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator\Annotation;
|
||||
|
||||
use Drupal\Component\Annotation\Plugin;
|
||||
|
||||
/**
|
||||
* Defines a Plugin annotation object for aggregator processor plugins.
|
||||
*
|
||||
* @Annotation
|
||||
*/
|
||||
class AggregatorProcessor extends Plugin {
|
||||
|
||||
/**
|
||||
* The plugin ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $id;
|
||||
|
||||
/**
|
||||
* The title of the plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Annotation\Translation
|
||||
*
|
||||
* @ingroup plugin_translatable
|
||||
*/
|
||||
public $title;
|
||||
|
||||
/**
|
||||
* The description of the plugin.
|
||||
*
|
||||
* @var \Drupal\Core\Annotation\Translation
|
||||
*
|
||||
* @ingroup plugin_translatable
|
||||
*/
|
||||
public $description;
|
||||
|
||||
}
|
|
@ -27,7 +27,17 @@ class AggregatorPluginManager extends PluginManagerBase {
|
|||
* keyed by the corresponding namespace to look for plugin implementations,
|
||||
*/
|
||||
public function __construct($type, \Traversable $namespaces) {
|
||||
$this->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);
|
||||
}
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -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.")
|
||||
|
|
|
@ -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.")
|
||||
|
|
Loading…
Reference in New Issue