You are here

FeedImportHashManager.php in Feed Import 8

File

feed_import_base/src/FeedImportHashManager.php
View source
<?php

namespace Drupal\feed_import_base;


/**
 * Class which provides methods to manage hashes.
 */
abstract class FeedImportHashManager extends FeedImportConfigurable implements FeedImportStaticHashManager {

  // Expire entities.
  protected $ttl = 0;

  // Generated hashes.
  protected $generatedHashes = array();

  // Item is marked as protected for updates.
  const MARK_PROTECTED = 1;

  /**
   * Constructor.
   */
  public abstract function __construct($entity_name, $feed_machine_name);

  /**
   * Returns an array of entity keyed by hash,
   * using generated hashes.
   *
   * @return array
   *     An array containing entity ids keyed by hash.
   */
  public abstract function get();

  /**
   * Inserts a new hash.
   *
   * @param integer $id
   *     Entity id
   * @param mixed $hash
   *     Unique hash coresponding to entity id
   * @param int $expire
   *     Time to live
   */
  public abstract function insert($id, $hash);

  /**
   * Commits the insert to storage.
   */
  public abstract function insertCommit();

  /**
   * Updates hashes.
   *
   * @param integer $id
   *     Hash id
   * @param int $expire
   *     Time to live
   */
  public abstract function update($id);

  /**
   * Protects a hash for updates
   *
   * @param integer $id
   *    Hash id
   */
  public abstract function protect($id);

  /**
   * Commits the update to storage.
   */
  public abstract function updateCommit();

  /**
   * Creates a hash, based on uniq
   * Also adds it on generated hashes
   *
   * @param mixed $uniq
   *     Unique identifier.
   *
   * @return string
   *     A hash for specified identifier.
   */
  public abstract function hash(&$uniq);

}

Classes

Namesort descending Description
FeedImportHashManager Class which provides methods to manage hashes.