You are here

public function EntityStatus::setLastPull in CMS Content Sync 8

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

Set the last pull timestamp.

Parameters

int $timestamp:

1 call to EntityStatus::setLastPull()
EntityStatus::resetStatus in src/Entity/EntityStatus.php

File

src/Entity/EntityStatus.php, line 880

Class

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

Namespace

Drupal\cms_content_sync\Entity

Code

public function setLastPull($timestamp) {
  if ($this
    ->getLastPull() == $timestamp) {
    return;
  }
  $this
    ->set('last_import', $timestamp);

  // As this pull was successful, we can now reset the flags for status entity resets and failed pulls.
  if (!empty($timestamp)) {
    $this
      ->wasLastPullReset(false);
    $this
      ->didPullFail(false);

    // Delete status entities without Flow assigned- they're no longer needed.
    $error_entities = EntityStatus::getInfosForEntity($this
      ->getEntityTypeName(), $this
      ->getUuid(), [
      'flow' => self::FLOW_NO_FLOW,
    ], true);
    foreach ($error_entities as $entity) {
      $entity
        ->delete();
    }
  }
  else {
    $this
      ->wasLastPullReset(true);
  }
}