class LinkStatusHandle in Link checker 8
Handler a status of a link.
Plugin annotation
@QueueWorker(
id = "linkchecker_status_handle",
title = @Translation("LinkChecker status handle"),
cron = {"time" = 60}
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\linkchecker\Plugin\QueueWorker\LinkStatusHandle implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of LinkStatusHandle
File
- src/
Plugin/ QueueWorker/ LinkStatusHandle.php, line 21
Namespace
Drupal\linkchecker\Plugin\QueueWorkerView source
class LinkStatusHandle extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The status handler manager.
*
* @var \Drupal\linkchecker\Plugin\LinkStatusHandlerManager
*/
protected $statusHandlerManager;
/**
* LinkExtract constructor.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, LinkStatusHandlerManager $statusHandlerManager) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entityTypeManager;
$this->statusHandlerManager = $statusHandlerManager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'), $container
->get('plugin.manager.link_status_handler'));
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
$response = $data['response'];
try {
/** @var \Drupal\linkchecker\Plugin\LinkStatusHandlerInterface $handler */
$handler = $this->statusHandlerManager
->createInstance($data['handler']);
} catch (PluginNotFoundException $e) {
// Skip it.
}
foreach ($data['links'] as $linkId) {
try {
/** @var \Drupal\linkchecker\LinkCheckerLinkInterface $link */
$link = $this->entityTypeManager
->getStorage('linkcheckerlink')
->load($linkId);
$handler
->handle($link, $response);
} catch (\Exception $e) {
// If we can`t load Link or entity - just skip it.
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LinkStatusHandle:: |
protected | property | The entity type manager. | |
LinkStatusHandle:: |
protected | property | The status handler manager. | |
LinkStatusHandle:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
LinkStatusHandle:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
LinkStatusHandle:: |
public | function |
LinkExtract constructor. 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. |