BrightcoveCustomFieldQueueWorker.php in Brightcove Video Connect 3.x
File
src/Plugin/QueueWorker/BrightcoveCustomFieldQueueWorker.php
View source
<?php
namespace Drupal\brightcove\Plugin\QueueWorker;
use Drupal\brightcove\Entity\BrightcoveCustomField;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\Core\Queue\QueueWorkerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
class BrightcoveCustomFieldQueueWorker 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_custom_field'));
}
public function processItem($data) {
$custom_field = $data['custom_field'];
BrightcoveCustomField::createOrUpdate($custom_field, $this->storage, $data['api_client_id']);
}
}