BrightcovePlayerQueueWorker.php in Brightcove Video Connect 8.2
File
src/Plugin/QueueWorker/BrightcovePlayerQueueWorker.php
View source
<?php
namespace Drupal\brightcove\Plugin\QueueWorker;
use Drupal\brightcove\Entity\BrightcovePlayer;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueWorkerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BrightcovePlayerQueueWorker extends QueueWorkerBase implements ContainerFactoryPluginInterface {
protected $storage;
public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityStorageInterface $storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->storage = $storage;
}
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_player'));
}
public function processItem($data) {
$player = $data['player'];
BrightcovePlayer::createOrUpdate($player, $this->storage, $data['api_client_id']);
}
}