You are here

public static function Flow::getFlowForPoolAndEntityType in CMS Content Sync 2.1.x

Get the first synchronization that allows the pull of the provided entity type.

Parameters

Pool $pool:

string $entity_type_name:

string $bundle_name:

string $reason:

string $action:

bool $strict:

Return value

null|Flow

3 calls to Flow::getFlowForPoolAndEntityType()
EntityResource::handleIncomingEntity in src/Plugin/rest/resource/EntityResource.php
FlowPull::force_pull_entity in src/Controller/FlowPull.php
Force pull an entity for a specific flow.
PullIntent::loadEmbeddedEntity in src/PullIntent.php
Restore an entity that was added via {{

File

src/Entity/Flow.php, line 418

Class

Flow
Defines the "Content Sync - Flow" entity.

Namespace

Drupal\cms_content_sync\Entity

Code

public static function getFlowForPoolAndEntityType($pool, $entity_type_name, $bundle_name, $reason, $action = SyncIntent::ACTION_CREATE, $strict = false) {
  $flows = self::getAll();

  // If $reason is DEPENDENCY and there's a Flow pulling AUTOMATICALLY we take that. But only if there's no Flow
  // explicitly handling this entity AS_DEPENDENCY.
  $fallback = null;
  foreach ($flows as $flow) {
    if ($pool && !in_array($pool, $flow
      ->getController()
      ->getUsedPoolsForPulling($entity_type_name, $bundle_name))) {
      continue;
    }
    if (!$flow
      ->getController()
      ->canPullEntity($entity_type_name, $bundle_name, $reason, $action, true)) {
      if (!$strict && $flow
        ->getController()
        ->canPullEntity($entity_type_name, $bundle_name, $reason, $action, false)) {
        $fallback = $flow;
      }
      continue;
    }
    return $flow;
  }
  if (!empty($fallback)) {
    return $fallback;
  }
  return null;
}