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