Commit 25ec0d14 authored by Steffen Schlaer's avatar Steffen Schlaer Committed by Steven Jones
Browse files

Issue #2887450 by steven jones, idebr, hfernandes, sstapleton, manuel garcia,...

Issue #2887450 by steven jones, idebr, hfernandes, sstapleton, manuel garcia, _randy, BS Pavan, giuseppe87, super_romeo, reszli, it-cru, anneke_vde, jaapjan, grndlvl, code_brown, minoroffense, matthiasm11, simgui8, p4trizio, doidd, pivica, a.ilyin, frantisekivanko, b-prod, sergiur, guillaumepacilly, pierreemmanuel, vengador, megha_kundar, patrickfweston, sachint1996, medha kumari, mscalone, eelkeblok, mellowtothemax, norman.lol, steinmb, leisurman, yazzbe, longwave, sakonn, escuriola, guillaumeduveau, tim-diels, killes@www.drop.org, atourino, alexdoma, sonfd, josephdpurcell, superlolo95, jhedstrom, joseph.olstad, ivnish, PhilippVerpoort, lee.cocklin, chiefme, error84: Re-add Drush commands
parent 0c877588
Loading
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -28,4 +28,3 @@ variables:
  SKIP_CSPELL: '1'
  # We want to test in Drupal 10 too.
  OPT_IN_TEST_PREVIOUS_MAJOR: 1
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
  "license": "GPL-2.0-or-later",
  "require": {
    "drupal/csv_serialization": "~1.4 || ~2.0 || ~3 || ~4",
    "php": ">=8.0"
    "php": ">=8.1"
  },
  "require-dev": {
    "drupal/search_api": "~1.12",
+24 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\views_data_export;

/**
 * Drupal adapter for batch processing.
 */
class BatchProcessingAdapterDrupal implements BatchProcessingAdapterInterface {

  /**
   * {@inheritdoc}
   */
  public function batchProcess() {
    return batch_process();
  }

  /**
   * {@inheritdoc}
   */
  public function getFinishedCallback(string $caller) {
    return [$caller, 'finishBatch'];
  }

}
+32 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\views_data_export;

/**
 * Drush adapter for batch processing.
 */
class BatchProcessingAdapterDrush implements BatchProcessingAdapterInterface {

  /**
   * {@inheritdoc}
   */
  public function batchProcess() {
    return drush_backend_batch_process();
  }

  /**
   * {@inheritdoc}
   */
  public function getFinishedCallback(string $caller) {
    return [static::class, 'finishBatchDrush'];
  }

  /**
   * Implements callback for batch finish when running from Drush.
   */
  public static function finishBatchDrush($success, array $results, array $operations) {
    // We don't need to do anything here. But without this callback, Drush does
    // not pass us the results correctly.
  }

}
+30 −0
Original line number Diff line number Diff line
<?php

namespace Drupal\views_data_export;

/**
 * Interface for batch processing adapters.
 *
 * This interface defines the methods required for batch processing in the
 * Views Data Export module, allowing for different implementations depending
 * on the context (e.g., Drupal or Drush).
 */
interface BatchProcessingAdapterInterface {

  /**
   * Process the batch.
   */
  public function batchProcess();

  /**
   * Returns the callback to be used for batch processing completion.
   *
   * @param string $caller
   *   The name of the class that will handle the batch completion.
   *
   * @return callable
   *   A callable that will be invoked when the batch processing is finished.
   */
  public function getFinishedCallback(string $caller);

}
Loading