EntityShareCronPending.php in Entity Share Cron 3.0.x
File
src/Plugin/QueueWorker/EntityShareCronPending.php
View source
<?php
declare (strict_types=1);
namespace Drupal\entity_share_cron\Plugin\QueueWorker;
use Drupal\Core\Queue\QueueWorkerBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\entity_share_cron\EntityShareCronServiceInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Psr\Log\LoggerInterface;
class EntityShareCronPending extends QueueWorkerBase implements ContainerFactoryPluginInterface {
protected $service;
protected $logger;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityShareCronServiceInterface $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.channel.entity_share_cron'));
}
public function processItem($data) {
$remote_id = $data['remote_id'];
$channel_id = $data['channel_id'];
$url = $data['url'];
$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, $url);
}
}