You are here

protected function EntityResource::saveFailedPull in CMS Content Sync 2.1.x

Same name and namespace in other branches
  1. 8 src/Plugin/rest/resource/EntityResource.php \Drupal\cms_content_sync\Plugin\rest\resource\EntityResource::saveFailedPull()
  2. 2.0.x src/Plugin/rest/resource/EntityResource.php \Drupal\cms_content_sync\Plugin\rest\resource\EntityResource::saveFailedPull()

Save that the pull for the given entity failed.

Parameters

string $pool_id: The Pool ID

$entity_type: The Entity Type ID

$entity_bundle: The bundle name

$entity_type_version: The requested entity type version

$entity_uuid: The entity UUID

$failure_reason:

$action:

$reason:

null $flow_id:

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

\Drupal\Component\Plugin\Exception\PluginNotFoundException

\Drupal\Core\Entity\EntityStorageException

1 call to EntityResource::saveFailedPull()
EntityResource::handleIncomingEntity in src/Plugin/rest/resource/EntityResource.php

File

src/Plugin/rest/resource/EntityResource.php, line 297

Class

EntityResource
Provides entity interfaces for Content Sync, allowing Sync Core to request and manipulate entities.

Namespace

Drupal\cms_content_sync\Plugin\rest\resource

Code

protected function saveFailedPull($pool_id, $entity_type, $entity_bundle, $entity_type_version, $entity_uuid, $failure_reason, $action, $reason, $flow_id = null) {
  $entity_status = EntityStatus::getInfoForEntity($entity_type, $entity_uuid, $flow_id, $pool_id);
  if (!$entity_status) {
    $entity_status = EntityStatus::create([
      'flow' => $flow_id ? $flow_id : EntityStatus::FLOW_NO_FLOW,
      'pool' => $pool_id,
      'entity_type' => $entity_type,
      'entity_uuid' => $entity_uuid,
      'entity_type_version' => $entity_type_version,
      'flags' => 0,
      'source_url' => null,
    ]);
  }
  $soft_fails = [
    PullIntent::PULL_FAILED_UNKNOWN_POOL,
    PullIntent::PULL_FAILED_NO_FLOW,
    PullIntent::PULL_FAILED_HANDLER_DENIED,
  ];
  $soft = in_array($failure_reason, $soft_fails);
  $entity_status
    ->didPullFail(true, $soft, [
    'error' => $failure_reason,
    'action' => $action,
    'reason' => $reason,
    'bundle' => $entity_bundle,
  ]);
  $entity_status
    ->save();
}