You are here

class FeedsQueueBatch in Feeds 8.3

A batch task for the queue API.

Hierarchy

Expanded class hierarchy of FeedsQueueBatch

File

src/FeedsQueueBatch.php, line 10

Namespace

Drupal\feeds
View source
class FeedsQueueBatch extends FeedsBatchBase {

  /**
   * The queue factory.
   *
   * @var \Drupal\Core\Queue\QueueFactory
   */
  protected $queueFactory;

  /**
   * Constructs a new FeedsQueueBatch object.
   *
   * @param \Drupal\feeds\FeedsExecutableInterface $executable
   *   The Feeds executable.
   * @param \Drupal\feeds\FeedInterface $feed
   *   The feed to run a batch for.
   * @param string $stage
   *   The stage of the batch to run.
   * @param \Drupal\Core\Queue\QueueFactory $queue_factory
   *   The queue factory.
   */
  public function __construct(FeedsExecutableInterface $executable, FeedInterface $feed, $stage, QueueFactory $queue_factory) {
    parent::__construct($executable, $feed, $stage);
    $this->queueFactory = $queue_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function run() {

    // Queue all operations now.
    foreach ($this->operations as $operation) {
      $this->queueFactory
        ->get('feeds_feed_refresh:' . $this->feed
        ->bundle())
        ->createItem([
        $this->feed,
        $operation['stage'],
        $operation['params'],
      ]);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeedsBatchBase::$executable protected property The Feeds executable.
FeedsBatchBase::$feed protected property The feed to run a batch for.
FeedsBatchBase::$operations protected property A list of operations to run.
FeedsBatchBase::$stage protected property The stage of the batch to run.
FeedsBatchBase::addOperation public function Adds an operation. Overrides FeedsBatchInterface::addOperation
FeedsQueueBatch::$queueFactory protected property The queue factory.
FeedsQueueBatch::run public function Runs the batch. Overrides FeedsBatchInterface::run
FeedsQueueBatch::__construct public function Constructs a new FeedsQueueBatch object. Overrides FeedsBatchBase::__construct