You are here

class EntityShareCronPending in Entity Share Cron 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/QueueWorker/EntityShareCronPending.php \Drupal\entity_share_cron\Plugin\QueueWorker\EntityShareCronPending
  2. 3.0.x src/Plugin/QueueWorker/EntityShareCronPending.php \Drupal\entity_share_cron\Plugin\QueueWorker\EntityShareCronPending

Imports entities from Entity Share channels.

Plugin annotation


@QueueWorker(
  id = "entity_share_cron_pending",
  title = @Translation("Entity Share Cron"),
  cron = {"time" = 10}
)

Hierarchy

Expanded class hierarchy of EntityShareCronPending

File

src/Plugin/QueueWorker/EntityShareCronPending.php, line 20

Namespace

Drupal\entity_share_cron\Plugin\QueueWorker
View source
class EntityShareCronPending extends QueueWorkerBase implements ContainerFactoryPluginInterface {
  const PAGE_LIMIT = 5;

  /**
   * Entity Share Cron service.
   *
   * @var \Drupal\entity_share_cron\EntityShareCronServiceInterface
   */
  protected $service;

  /**
   * Logger.
   *
   * @var \Psr\Log\LoggerInterface
   */
  protected $logger;

  /**
   * Constructor.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\entity_share_cron\EntityShareCronService $service
   *   Entity Share Cron service.
   * @param \Psr\Log\LoggerInterface $logger
   *   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;
  }

  /**
   * {@inheritdoc}
   */
  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'));
  }

  /**
   * {@inheritdoc}
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityShareCronPending::$logger protected property Logger.
EntityShareCronPending::$service protected property Entity Share Cron service.
EntityShareCronPending::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
EntityShareCronPending::PAGE_LIMIT constant
EntityShareCronPending::processItem public function Works on a single queue item. Overrides QueueWorkerInterface::processItem
EntityShareCronPending::__construct public function Constructor. Overrides PluginBase::__construct
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 3
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.