<?php

namespace Drupal\openstreetmap;

use Drupal\Core\Entity\ContentEntityStorageInterface;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\openstreetmap\Entity\OSMNode;

/**
 * Defines an interface for osm_node entity storage classes.
 */
interface OSMNodeStorageInterface extends ContentEntityStorageInterface {

  /**
   * Gets a list of osm_node revision IDs for a specific osm_node.
   *
   * @param \Drupal\openstreetmap\Entity\OSMNode $osm_node
   *   The osm_node entity.
   *
   * @return int[]
   *   OSMNode revision IDs (in ascending order).
   */
  public function revisionIds(OSMNode $osm_node);

  /**
   * Gets a list of revision IDs having a given user as osm_node author.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The user entity.
   *
   * @return int[]
   *   OSMNode revision IDs (in ascending order).
   */
  public function userRevisionIds(AccountInterface $account);

  /**
   * Counts the number of revisions in the default language.
   *
   * @param \Drupal\openstreetmap\Entity\OSMNode $osm_node
   *   The osm_node entity.
   *
   * @return int
   *   The number of revisions in the default language.
   */
  public function countDefaultLanguageRevisions(OSMNode $osm_node);

  /**
   * Updates all osm_nodes of one type to be of another type.
   *
   * @param string $old_type
   *   The current osm_node type of the osm_nodes.
   * @param string $new_type
   *   The new osm_node type of the osm_nodes.
   *
   * @return int
   *   The number of osm_nodes whose osm_node type field was modified.
   */
  public function updateType($old_type, $new_type);

  /**
   * Unsets the language for all osm_nodes with the given language.
   *
   * @param \Drupal\Core\Language\LanguageInterface $language
   *   The language object.
   */
  public function clearRevisionsLanguage(LanguageInterface $language);

}
