abstract class FeedQueueWorkerBase in Feeds 8.3
Base class for Feed queue workers.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\feeds\Plugin\QueueWorker\FeedQueueWorkerBase implements ContainerFactoryPluginInterface uses EventDispatcherTrait
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of FeedQueueWorkerBase
File
- src/
Plugin/ QueueWorker/ FeedQueueWorkerBase.php, line 20
Namespace
Drupal\feeds\Plugin\QueueWorkerView source
abstract class FeedQueueWorkerBase extends QueueWorkerBase implements ContainerFactoryPluginInterface {
use EventDispatcherTrait;
/**
* The account switcher.
*
* @var \Drupal\Core\Session\AccountSwitcherInterface
*/
protected $accountSwitcher;
/**
* The queue factory.
*
* @var \Drupal\Core\Queue\QueueFactory
*/
protected $queueFactory;
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a FeedQueueWorkerBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param array $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Queue\QueueFactory $queue_factory
* The queue factory.
* @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
* The event dispatcher.
* @param \Drupal\Core\Session\AccountSwitcherInterface $account_switcher
* The account switcher.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, QueueFactory $queue_factory, EventDispatcherInterface $event_dispatcher, AccountSwitcherInterface $account_switcher, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->queueFactory = $queue_factory;
$this
->setEventDispatcher($event_dispatcher);
$this->accountSwitcher = $account_switcher;
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('queue'), $container
->get('event_dispatcher'), $container
->get('account_switcher'), $container
->get('entity_type.manager'));
}
/**
* Handles an import exception.
*/
protected function handleException(FeedInterface $feed, \Exception $exception) {
$feed
->finishImport();
if (!$exception instanceof EmptyFeedException) {
throw $exception;
}
}
/**
* Safely switches to another account.
*
* @param \Drupal\feeds\FeedInterface $feed
* The feed that has the account to switch to.
*
* @return \Drupal\Core\Session\AccountSwitcherInterface
* The account switcher to call switchBack() on.
*
* @see \Drupal\Core\Session\AccountSwitcherInterface::switchTo()
*/
protected function switchAccount(FeedInterface $feed) {
$account = new AccountProxy($this
->getEventDispatcher());
$account
->setInitialAccountId($feed
->getOwnerId());
return $this->accountSwitcher
->switchTo($account);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EventDispatcherTrait:: |
private | property | The event dispatcher service. | |
EventDispatcherTrait:: |
protected | function | Dispatches an event. | |
EventDispatcherTrait:: |
protected | function | Returns the event dispatcher service. | |
EventDispatcherTrait:: |
public | function | Sets the event dispatcher service to use. | |
FeedQueueWorkerBase:: |
protected | property | The account switcher. | |
FeedQueueWorkerBase:: |
protected | property | The entity type manager. | |
FeedQueueWorkerBase:: |
protected | property | The queue factory. | |
FeedQueueWorkerBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
FeedQueueWorkerBase:: |
protected | function | Handles an import exception. | |
FeedQueueWorkerBase:: |
protected | function | Safely switches to another account. | |
FeedQueueWorkerBase:: |
public | function |
Constructs a FeedQueueWorkerBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
QueueWorkerInterface:: |
public | function | Works on a single queue item. | 6 |