FeedsPluginManager.php in Feeds 8.3
File
src/Plugin/Type/FeedsPluginManager.php
View source
<?php
namespace Drupal\feeds\Plugin\Type;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\feeds\Plugin\Discovery\OverridableDerivativeDiscoveryDecorator;
class FeedsPluginManager extends DefaultPluginManager {
protected $pluginType;
public function __construct($type, \Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler) {
$type_annotations = [
'fetcher' => 'Drupal\\feeds\\Annotation\\FeedsFetcher',
'parser' => 'Drupal\\feeds\\Annotation\\FeedsParser',
'processor' => 'Drupal\\feeds\\Annotation\\FeedsProcessor',
'source' => 'Drupal\\feeds\\Annotation\\FeedsSource',
'target' => 'Drupal\\feeds\\Annotation\\FeedsTarget',
];
$plugin_interfaces = [
'fetcher' => 'Drupal\\feeds\\Plugin\\Type\\Fetcher\\FetcherInterface',
'parser' => 'Drupal\\feeds\\Plugin\\Type\\Parser\\ParserInterface',
'processor' => 'Drupal\\feeds\\Plugin\\Type\\Processor\\ProcessorInterface',
'source' => 'Drupal\\feeds\\Plugin\\Type\\Source\\SourceInterface',
'target' => 'Drupal\\feeds\\Plugin\\Type\\Target\\TargetInterface',
];
$this->pluginType = $type;
$this->subdir = 'Feeds/' . ucfirst($type);
$this->discovery = new AnnotatedClassDiscovery($this->subdir, $namespaces, $type_annotations[$type]);
$this->discovery = new OverridableDerivativeDiscoveryDecorator($this->discovery);
$this->factory = new FeedsAnnotationFactory($this, $plugin_interfaces[$type]);
$this->moduleHandler = $module_handler;
$this
->alterInfo("feeds_{$type}_plugins");
$this
->setCacheBackend($cache_backend, "feeds_{$type}_plugins");
}
public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
$definition['plugin_type'] = $this->pluginType;
if (!isset($definition['form']['configuration']) && isset($definition['class']) && is_subclass_of($definition['class'], PluginFormInterface::class)) {
$definition['form']['configuration'] = $definition['class'];
}
}
}