You are here

public function VersionComparison::doComparisonOnDelete in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.1.x modules/cms_content_sync_developer/src/EventSubscriber/VersionComparison.php \Drupal\cms_content_sync_developer\EventSubscriber\VersionComparison::doComparisonOnDelete()
  2. 2.0.x modules/cms_content_sync_developer/src/EventSubscriber/VersionComparison.php \Drupal\cms_content_sync_developer\EventSubscriber\VersionComparison::doComparisonOnDelete()

Check for config changes on delete.

Parameters

\Drupal\Core\Config\ConfigCrudEvent $event: The Event to process.

File

modules/cms_content_sync_developer/src/EventSubscriber/VersionComparison.php, line 128

Class

VersionComparison
A subscriber triggering a config when certain configuration changes.

Namespace

Drupal\cms_content_sync_developer\EventSubscriber

Code

public function doComparisonOnDelete(ConfigCrudEvent $event) {

  // Very comparison is not done if config got changed by CLI.
  if (!in_array(PHP_SAPI, [
    'cli',
    'cli-server',
    'phpdbg',
  ])) {
    $saved_config = $event
      ->getConfig();
    $old_config = $saved_config
      ->getOriginal();
    if (isset($old_config['entity_type']) && isset($old_config['bundle'])) {
      $flows = Flow::getAll();
      $mismatching_flows = [];
      foreach ($flows as $flow_id => $flow) {

        // Entity Type and bundle are not set consistent between the entity types.
        $entity_type = $this
          ->getEntityTypeFromConfig($old_config);
        $bundle = $this
          ->getBundleFromConfig($old_config);
        if (isset($entity_type) && isset($bundle)) {
          $entity_type_config = $flow
            ->getEntityTypeConfig($entity_type, $bundle);
          if (isset($entity_type_config['handler'])) {
            $mismatching_flows[$flow_id] = $flow
              ->label();
            $this
              ->setMismatchingFlows($mismatching_flows);
          }
        }
      }
    }
  }
}