EntityShareCronPending.php in Entity Share Cron 8
File
src/Plugin/QueueWorker/EntityShareCronPending.php
View source
<?php
namespace Drupal\entity_share_cron\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\entity_share_cron\EntityShareCronService;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Psr\Log\LoggerInterface;
class EntityShareCronPending extends QueueWorkerBase implements ContainerFactoryPluginInterface {
const PAGE_LIMIT = 5;
protected $service;
protected $logger;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityShareCronService $service, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->service = $service;
$this->logger = $logger;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_share_cron'), $container
->get('logger.factory')
->get('entitiy_share_cron'));
}
public function processItem($data) {
$remote_id = $data['remote_id'];
$channel_id = $data['channel_id'];
$channel_info = $data['channel_info'];
$this->logger
->info('Importing entities from channel %channel_id from remote %remote_id.', [
'%channel_id' => $channel_id,
'%remote_id' => $remote_id,
]);
$this->service
->sync($remote_id, $channel_id, $channel_info, self::PAGE_LIMIT);
}
}