class BrightcoveVideoQueueWorker in Brightcove Video Connect 8.2
Same name and namespace in other branches
- 8 src/Plugin/QueueWorker/BrightcoveVideoQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveVideoQueueWorker
- 3.x src/Plugin/QueueWorker/BrightcoveVideoQueueWorker.php \Drupal\brightcove\Plugin\QueueWorker\BrightcoveVideoQueueWorker
Processes Entity Update Tasks for Video.
Plugin annotation
@QueueWorker(
id = "brightcove_video_queue_worker",
title = @Translation("Brightcove video 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\BrightcoveVideoQueueWorker implements ContainerFactoryPluginInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of BrightcoveVideoQueueWorker
File
- src/
Plugin/ QueueWorker/ BrightcoveVideoQueueWorker.php, line 23
Namespace
Drupal\brightcove\Plugin\QueueWorkerView source
class BrightcoveVideoQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
/**
* The brightcove_video storage.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $storage;
/**
* Entity query factory.
*
* @var \Drupal\Core\Database\Connection
*/
protected $connection;
/**
* The playlist page queue object.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected $textTrackQueue;
/**
* The playlist page queue object.
*
* @var \Drupal\Core\Queue\QueueInterface
*/
protected $textTrackDeleteQueue;
/**
* Constructs a new BrightcoveVideoQueueWorker 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\Entity\EntityStorageInterface $storage
* The storage object.
* @param \Drupal\Core\Database\Connection $connection
* Database connection.
* @param \Drupal\Core\Queue\QueueInterface $text_track_queue
* Text track queue object.
* @param \Drupal\Core\Queue\QueueInterface $text_track_delete_queue
* Text track delete queue object.
*/
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageInterface $storage, Connection $connection, QueueInterface $text_track_queue, QueueInterface $text_track_delete_queue) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->storage = $storage;
$this->connection = $connection;
$this->textTrackQueue = $text_track_queue;
$this->textTrackDeleteQueue = $text_track_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('entity_type.manager')
->getStorage('brightcove_video'), $container
->get('database'), $container
->get('queue')
->get('brightcove_text_track_queue_worker'), $container
->get('queue')
->get('brightcove_text_track_delete_queue_worker'));
}
/**
* {@inheritdoc}
*/
public function processItem($data) {
/** @var \Brightcove\Item\Video\Video $video */
$video = $data['video'];
/** @var \Drupal\brightcove\Entity\BrightcoveVideo $video_entity */
$video_entity = BrightcoveVideo::createOrUpdate($video, $this->storage, $data['api_client_id']);
if (!empty($video_entity)) {
// Get existing text tracks.
$existing_text_tracks = [];
foreach ($video_entity
->getTextTracks() as $text_track) {
/** @var \Drupal\brightcove\Entity\BrightcoveTextTrack $text_track_entity */
$text_track_entity = BrightcoveTextTrack::load($text_track['target_id']);
if (!is_null($text_track_entity)) {
$existing_text_tracks[$text_track_entity
->getTextTrackId()] = TRUE;
}
}
// Save Video text tracks.
$text_tracks = $video
->getTextTracks();
foreach ($text_tracks as $text_track) {
// Remove existing text tracks from the list which are still existing on
// Brightcove.
if (isset($existing_text_tracks[$text_track
->getId()])) {
unset($existing_text_tracks[$text_track
->getId()]);
}
// Create new queue item for text track.
$this->textTrackQueue
->createItem([
'text_track' => $text_track,
'video_entity_id' => $video_entity
->id(),
]);
}
// Remove existing text tracks which are no longer available on
// Brightcove.
foreach (array_keys($existing_text_tracks) as $text_track_id) {
// Create new delete queue item for text track.
$this->textTrackDeleteQueue
->createItem($text_track_id);
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BrightcoveVideoQueueWorker:: |
protected | property | Entity query factory. | |
BrightcoveVideoQueueWorker:: |
protected | property | The brightcove_video storage. | |
BrightcoveVideoQueueWorker:: |
protected | property | The playlist page queue object. | |
BrightcoveVideoQueueWorker:: |
protected | property | The playlist page queue object. | |
BrightcoveVideoQueueWorker:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
BrightcoveVideoQueueWorker:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
BrightcoveVideoQueueWorker:: |
public | function |
Constructs a new BrightcoveVideoQueueWorker 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. |