You are here

public static function EntityStatus::getInfoForEntity in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::getInfoForEntity()
  2. 2.1.x src/Entity/EntityStatus.php \Drupal\cms_content_sync\Entity\EntityStatus::getInfoForEntity()

Parameters

string $entity_type:

string $entity_uuid:

Flow|string $flow:

Pool|string $pool:

Return value

EntityStatus|mixed

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Exception

9 calls to EntityStatus::getInfoForEntity()
CreateStatusEntities::execute in modules/cms_content_sync_migrate_acquia_content_hub/src/CreateStatusEntities.php
Batch create Status Entities for collected nodes.
EntityResource::saveFailedPull in src/Plugin/rest/resource/EntityResource.php
Save that the pull for the given entity failed.
EntityStatus::saveSelectedPoolsToPushTo in src/Entity/EntityStatus.php
Flow::getPoolsToPushTo in src/Entity/Flow.php
Get a list of all pools that are used for pushing this entity, either automatically or manually selected.
MergeableEntityReferenceHandler::setValues in src/Plugin/cms_content_sync/field_handler/MergeableEntityReferenceHandler.php

... See full list

File

src/Entity/EntityStatus.php, line 200

Class

EntityStatus
Defines the "Content Sync - Entity Status" entity type.

Namespace

Drupal\cms_content_sync\Entity

Code

public static function getInfoForEntity($entity_type, $entity_uuid, $flow, $pool = null) {
  if (!$entity_type) {
    throw new \Exception('$entity_type is required.');
  }
  if (!$entity_uuid) {
    throw new \Exception('$entity_uuid is required.');
  }
  $filter = [
    'entity_type' => $entity_type,
    'entity_uuid' => $entity_uuid,
  ];
  if ($pool) {
    $filter['pool'] = is_string($pool) ? $pool : $pool->id;
  }
  if ($flow) {
    $filter['flow'] = is_string($flow) ? $flow : $flow->id;
  }
  else {
    $filter['flow'] = self::FLOW_NO_FLOW;
  }

  /**
   * @var EntityStatus[] $entities
   */
  $entities = \Drupal::entityTypeManager()
    ->getStorage('cms_content_sync_entity_status')
    ->loadByProperties($filter);
  if (!$flow) {
    foreach ($entities as $entity) {
      if (!$entity
        ->getFlow()) {
        return $entity;
      }
    }
    return null;
  }
  return reset($entities);
}