class FeedRefresh in Feeds 8.3
A queue worker for importing feeds.
Plugin annotation
@QueueWorker(
id = "feeds_feed_refresh",
title = @Translation("Feed refresh"),
cron = {"time" = 60},
deriver = "Drupal\feeds\Plugin\Derivative\FeedQueueWorker"
)
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\feeds\Plugin\QueueWorker\FeedRefresh
- class \Drupal\feeds\Plugin\QueueWorker\FeedQueueWorkerBase implements ContainerFactoryPluginInterface uses EventDispatcherTrait
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of FeedRefresh
1 file declares its use of FeedRefresh
- FeedRefreshTest.php in tests/
src/ Unit/ Plugin/ QueueWorker/ FeedRefreshTest.php
File
- src/
Plugin/ QueueWorker/ FeedRefresh.php, line 18
Namespace
Drupal\feeds\Plugin\QueueWorkerView source
class FeedRefresh extends FeedQueueWorkerBase {
/**
* {@inheritdoc}
*/
public function processItem($data) {
list($feed, $stage, $params) = $data;
if (!$feed instanceof FeedInterface) {
return;
}
// Check if the feed still exists.
if (!$this
->feedExists($feed)) {
// The feed in question has been deleted. Abort.
return;
}
$this
->getExecutable()
->processItem($feed, $stage, $params);
}
/**
* Returns Feeds executable.
*
* @return \Drupal\feed\FeedsExecutableInterface
* A feeds executable.
*/
protected function getExecutable() {
return \Drupal::service('class_resolver')
->getInstanceFromDefinition(FeedsQueueExecutable::class);
}
/**
* Returns if a feed entity still exists or not.
*
* @param \Drupal\feeds\FeedInterface $feed
* The feed entity to check for existance in the database.
*
* @return bool
* True if the feed still exists, false otherwise.
*/
protected function feedExists(FeedInterface $feed) {
// Check if the feed still exists.
$result = $this->entityTypeManager
->getStorage($feed
->getEntityTypeId())
->getQuery()
->condition('fid', $feed
->id())
->execute();
if (empty($result)) {
// The feed in question has been deleted.
return FALSE;
}
return TRUE;
}
}
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:: |
|
FeedRefresh:: |
protected | function | Returns if a feed entity still exists or not. | |
FeedRefresh:: |
protected | function | Returns Feeds executable. | |
FeedRefresh:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
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. |