You are here

public static function SyncCoreFlowExport::deleteUnusedFlows in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 2.1.x src/SyncCoreFlowExport.php \Drupal\cms_content_sync\SyncCoreFlowExport::deleteUnusedFlows()
5 calls to SyncCoreFlowExport::deleteUnusedFlows()
CliService::configuration_export in src/Cli/CliService.php
Export the configuration to the Sync Core.
ConfigSubscriber::deleteUnusedFlows in src/EventSubscriber/ConfigSubscriber.php
Delete unsed remote flows after config deletion.
FlowExport::batchFinished in src/Controller/FlowExport.php
Batch export finished callback.
FlowExport::export in src/Controller/FlowExport.php
Export flow.
SetFlowStatus::setStatus in src/Controller/SetFlowStatus.php
Set flow status.

File

src/SyncCoreFlowExport.php, line 45

Class

SyncCoreFlowExport
Class SyncCoreFlowExport used to export the Synchronization config to the Sync Core backend.

Namespace

Drupal\cms_content_sync

Code

public static function deleteUnusedFlows() {
  if (Migration::alwaysUseV2()) {
    $keep_flows = [];

    // Get all active Flows and add them to the "keep list".
    foreach (Flow::getAll() as $flow) {
      $keep_flows[] = $flow->id;
    }
    $core = SyncCoreFactory::getSyncCoreV2();

    // We are deleting all that are not in the "keep list". This is the
    // most reliable way to delete all unwanted configuration as we
    // may not always be informed about changes of Flows (e.g. when
    // customers use a database dump for deployment or setup), and we
    // want the Flow status to be in sync to avoid unnecessary requests
    // and failures.
    $core
      ->getConfigurationService()
      ->deleteFlows($keep_flows);
  }
}