You are here

final class FileLinkQueueItem in File Link 2.0.x

Data object for a queue item to update a file link data.

Hierarchy

Expanded class hierarchy of FileLinkQueueItem

2 files declare their use of FileLinkQueueItem
FileLinkItem.php in src/Plugin/Field/FieldType/FileLinkItem.php
FileLinkMetadataUpdate.php in src/Plugin/QueueWorker/FileLinkMetadataUpdate.php

File

src/FileLinkQueueItem.php, line 10

Namespace

Drupal\file_link
View source
final class FileLinkQueueItem {

  /**
   * The request time of when the entity was queued.
   *
   * @var int
   */
  private $time;

  /**
   * The entity type.
   *
   * @var string
   */
  private $type;

  /**
   * The entity id, this only works on content entities.
   *
   * @var int
   */
  private $id;

  /**
   * The revision id for revisionable entity types.
   *
   * @var int|null
   */
  private $revisionId;

  /**
   * The language code for translatable entities.
   *
   * @var string
   */
  private $lang;

  /**
   * FileLinkQueueItem constructor.
   *
   * @param string $type
   *   The entity type.
   * @param int $id
   *   The entity id.
   * @param string $lang
   *   The language code.
   * @param int|null $revisionId
   *   The revision id.
   * @param int|null $time
   *   The timestamp.
   */
  public function __construct(string $type, int $id, string $lang = Language::LANGCODE_NOT_SPECIFIED, int $revisionId = NULL, int $time = NULL) {
    $this->type = $type;
    $this->id = $id;
    $this->lang = $lang;
    $this->revisionId = $revisionId;
    if ($time === NULL) {
      $time = \Drupal::time()
        ->getRequestTime();
    }
    $this->time = $time;
  }

  /**
   * Get the time of the queue.
   *
   * @return int
   *   The timestamp.
   */
  public function getTime() : int {
    return $this->time;
  }

  /**
   * Get the entity type.
   *
   * @return string
   *   The entity type.
   */
  public function getType() : string {
    return $this->type;
  }

  /**
   * Get the entity id.
   *
   * @return int
   *   The entity id.
   */
  public function getId() : int {
    return $this->id;
  }

  /**
   * Get the revision Id.
   *
   * @return int|null
   *   The revision id.
   */
  public function getRevisionId() {
    return $this->revisionId;
  }

  /**
   * Get the entity language.
   *
   * @return string
   *   The entity language
   */
  public function getLang() : string {
    return $this->lang;
  }

  /**
   * Get a key to keep track of queued items.
   *
   * @return string
   *   The key which identifies the queued entity variation.
   */
  public function getKey() : string {
    return $this
      ->getType() . $this
      ->getId() . $this
      ->getLang() . $this
      ->getRevisionId() ?? '';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FileLinkQueueItem::$id private property The entity id, this only works on content entities.
FileLinkQueueItem::$lang private property The language code for translatable entities.
FileLinkQueueItem::$revisionId private property The revision id for revisionable entity types.
FileLinkQueueItem::$time private property The request time of when the entity was queued.
FileLinkQueueItem::$type private property The entity type.
FileLinkQueueItem::getId public function Get the entity id.
FileLinkQueueItem::getKey public function Get a key to keep track of queued items.
FileLinkQueueItem::getLang public function Get the entity language.
FileLinkQueueItem::getRevisionId public function Get the revision Id.
FileLinkQueueItem::getTime public function Get the time of the queue.
FileLinkQueueItem::getType public function Get the entity type.
FileLinkQueueItem::__construct public function FileLinkQueueItem constructor.