class BrightcoveSubscriptionsQueueWorker in Brightcove Video Connect 8
Same name and namespace in other branches
- 8.2 src/Plugin/QueueWorker/BrightcoveSubscriptionsQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveSubscriptionsQueueWorker
- 3.x src/Plugin/QueueWorker/BrightcoveSubscriptionsQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveSubscriptionsQueueWorker
Gathers the subscriptions for creation and delete check.
Plugin annotation
@QueueWorker(
  id = "brightcove_subscriptions_queue_worker",
  title = @Translation("Brightcove subscriptions 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\BrightcoveSubscriptionsQueueWorker implements ContainerFactoryPluginInterface
 
 
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of BrightcoveSubscriptionsQueueWorker
File
- src/Plugin/ QueueWorker/ BrightcoveSubscriptionsQueueWorker.php, line 23 
Namespace
Drupal\brightcove\Plugin\QueueWorkerView source
class BrightcoveSubscriptionsQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
  /**
   * The brightcove_subscription create queue.
   *
   * @var \Drupal\Core\Queue\QueueInterface
   */
  protected $subscriptionQueue;
  /**
   * The brightcove_delete_subscription queue.
   *
   * @var \Drupal\Core\Queue\QueueInterface
   */
  protected $subscriptionDeleteQueue;
  /**
   * Constructs a new BrightcoveSubscriptionQueueWorker 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\QueueInterface $subscription_queue
   *   The brightcove_subscription queue.
   * @param \Drupal\Core\Queue\QueueInterface $subscription_delete_queue
   *   The brightcove_delete_subscription queue.
   */
  public function __construct(array $configuration, $plugin_id, array $plugin_definition, QueueInterface $subscription_queue, QueueInterface $subscription_delete_queue) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->subscriptionQueue = $subscription_queue;
    $this->subscriptionDeleteQueue = $subscription_delete_queue;
  }
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('queue')
      ->get('brightcove_subscription_queue_worker'), $container
      ->get('queue')
      ->get('brightcove_subscription_delete_queue_worker'));
  }
  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    $cms = BrightcoveUtil::getCmsApi($data);
    try {
      $subscriptions = $cms
        ->getSubscriptions();
      foreach (!empty($subscriptions) ? $subscriptions : [] as $subscription) {
        if ($subscription instanceof Subscription) {
          $this->subscriptionQueue
            ->createItem([
            'api_client_id' => $data,
            'subscription' => $subscription,
          ]);
        }
      }
    } catch (APIException $e) {
      if ($e
        ->getCode() == 401) {
        watchdog_exception('brightcove', $e, 'Access denied for Notifications.', [], RfcLogLevel::WARNING);
      }
      else {
        throw $e;
      }
    }
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| BrightcoveSubscriptionsQueueWorker:: | protected | property | The brightcove_delete_subscription queue. | |
| BrightcoveSubscriptionsQueueWorker:: | protected | property | The brightcove_subscription create queue. | |
| BrightcoveSubscriptionsQueueWorker:: | public static | function | Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: | |
| BrightcoveSubscriptionsQueueWorker:: | public | function | Works on a single queue item. Overrides QueueWorkerInterface:: | |
| BrightcoveSubscriptionsQueueWorker:: | public | function | Constructs a new BrightcoveSubscriptionQueueWorker 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. | 
