class BrightcoveSubscriptionDeleteQueueWorker in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/Plugin/QueueWorker/BrightcoveSubscriptionDeleteQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveSubscriptionDeleteQueueWorker
- 3.x src/Plugin/QueueWorker/BrightcoveSubscriptionDeleteQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveSubscriptionDeleteQueueWorker
Processes Entity Sync Tasks for Subscription.
Plugin annotation
@QueueWorker(
id = "brightcove_subscription_delete_queue_worker",
title = @Translation("Brightcove subscription queue worker."),
cron = { "time" = 30 }
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\brightcove\Plugin\QueueWorker\BrightcoveSubscriptionDeleteQueueWorker
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of BrightcoveSubscriptionDeleteQueueWorker
File
- src/
Plugin/ QueueWorker/ BrightcoveSubscriptionDeleteQueueWorker.php, line 20
Namespace
Drupal\brightcove\Plugin\QueueWorkerView source
class BrightcoveSubscriptionDeleteQueueWorker extends QueueWorkerBase {
/**
* {@inheritdoc}
*/
public function processItem($data) {
/** @var array $data */
if (!empty($data['local_only'])) {
$brightcove_subscription = BrightcoveSubscription::loadByBcSid($data['subscription_id']);
if (!empty($brightcove_subscription)) {
$brightcove_subscription
->delete(TRUE);
}
}
else {
// Check the Subscription if it is available on Brightcove or not.
try {
$cms = BrightcoveUtil::getCmsApi($data['api_client_id']);
$cms
->getSubscription($data['subscription_id']);
} catch (APIException $e) {
// If we got a not found response, delete the local version of the
// subscription.
if ($e
->getCode() == 404) {
/** @var \Drupal\brightcove\Entity\BrightcoveSubscription $subscription */
$brightcove_subscription = BrightcoveSubscription::loadByBcSid($data['subscription_id']);
if (!empty($brightcove_subscription)) {
// In case of a default subscription, unset the entity's
// association with the Brightcove entity, but keep a local entity
// in Drupal without the Brightcove ID and set its status to
// disabled.
if ($brightcove_subscription
->isDefault()) {
$brightcove_subscription
->setBcSid(NULL);
$brightcove_subscription
->setStatus(FALSE);
$brightcove_subscription
->save();
}
else {
$brightcove_subscription
->delete(TRUE);
}
}
}
elseif ($e
->getCode() == 401) {
watchdog_exception('brightcove', $e, 'Access denied for Notification.', [], RfcLogLevel::WARNING);
}
else {
throw $e;
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BrightcoveSubscriptionDeleteQueueWorker:: |
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. | |
PluginBase:: |
public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. | 92 |