You are here

class BrightcoveVideoPageQueueWorker in Brightcove Video Connect 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/QueueWorker/BrightcoveVideoPageQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveVideoPageQueueWorker
  2. 3.x src/Plugin/QueueWorker/BrightcoveVideoPageQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveVideoPageQueueWorker

Processes Entity Update Tasks for Video.

Plugin annotation


@QueueWorker(
  id = "brightcove_video_page_queue_worker",
  title = @Translation("Brightcove client queue worker."),
  cron = { "time" = 30 }
)

Hierarchy

Expanded class hierarchy of BrightcoveVideoPageQueueWorker

File

src/Plugin/QueueWorker/BrightcoveVideoPageQueueWorker.php, line 20

Namespace

Drupal\brightcove\Plugin\QueueWorker
View source
class BrightcoveVideoPageQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {

  /**
   * The video queue object.
   *
   * @var \Drupal\Core\Queue\QueueInterface
   */
  protected $videoQueue;

  /**
   * Constructs a new BrightcoveVideoPageQueueWorker 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 $video_queue
   *   The queue object.
   */
  public function __construct(array $configuration, $plugin_id, array $plugin_definition, QueueInterface $video_queue) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->videoQueue = $video_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_video_queue_worker'));
  }

  /**
   * {@inheritdoc}
   */
  public function processItem($data) {
    $cms = BrightcoveUtil::getCmsApi($data['api_client_id']);

    // Get videos.
    $videos = $cms
      ->listVideos(NULL, 'created_at', $data['items_per_page'], $data['page'] * $data['items_per_page']);
    foreach ($videos as $video) {
      $this->videoQueue
        ->createItem([
        'api_client_id' => $data['api_client_id'],
        'video' => $video,
      ]);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BrightcoveVideoPageQueueWorker::$videoQueue protected property The video queue object.
BrightcoveVideoPageQueueWorker::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
BrightcoveVideoPageQueueWorker::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
BrightcoveVideoPageQueueWorker::__construct public function Constructs a new BrightcoveVideoPageQueueWorker object. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.