You are here

public function Flow::getPoolsToPushTo in CMS Content Sync 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/Flow.php \Drupal\cms_content_sync\Entity\Flow::getPoolsToPushTo()

Get a list of all pools that are used for pushing this entity, either automatically or manually selected.

Parameters

string|string[] $reason: {@see Flow::PUSH_*}

string $action: {@see ::ACTION_*}

bool $include_forced: Include forced pools. Otherwise only use-selected / referenced ones.

Return value

Pool[]

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

File

src/Entity/Flow.php, line 370

Class

Flow
Defines the "Content Sync - Flow" entity.

Namespace

Drupal\cms_content_sync\Entity

Code

public function getPoolsToPushTo(EntityInterface $entity, $reason, $action, $include_forced = true) {
  $config = $this
    ->getEntityTypeConfig($entity
    ->getEntityTypeId(), $entity
    ->bundle());
  if (!$this
    ->canPushEntity($entity, $reason, $action)) {
    return [];
  }
  $result = [];
  $pools = Pool::getAll();
  foreach ($config['export_pools'] as $id => $setting) {
    if (!isset($pools[$id])) {
      continue;
    }
    $pool = $pools[$id];
    if (Pool::POOL_USAGE_FORBID == $setting) {
      continue;
    }
    if (Pool::POOL_USAGE_FORCE == $setting) {
      if ($include_forced) {
        $result[$id] = $pool;
      }
      continue;
    }
    $entity_status = EntityStatus::getInfoForEntity($entity
      ->getEntityTypeId(), $entity
      ->uuid(), $this, $pool);
    if ($entity_status && $entity_status
      ->isPushEnabled()) {
      $result[$id] = $pool;
    }
  }
  return $result;
}