Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3declare(strict_types=1);
4
5namespace Drupal\display_builder\Entity;
6
7/**
8 * History interface.
9 *
10 * When you implement Undo and Redo, you want to keep track of the history
11 * of this state at different points in time.
12 *
13 * Inspired from https://redux.js.org/usage/implementing-undo-history
14 */
15interface HistoryInterface {
16
17  /**
18   * Get the state of the current step.
19   *
20   * @return array
21   *   The current state.
22   */
23  public function getCurrentState(): array;
24
25  /**
26   * Set a new present.
27   *
28   * @param array $state
29   *   The state to set.
30   * @param string|\Stringable $log_message
31   *   (Optional) The log message.
32   * @param bool $check_hash
33   *   (Optional) Should check hash to avoid duplicates. Default to TRUE.
34   * @param bool $index
35   *   (Optional) When TRUE the raw $state is normalized through SourceTree
36   *   before storing. Set to FALSE when the data was already produced by
37   *   SourceTree::getTree() to skip redundant normalization. Default to TRUE.
38   */
39  public function setNewPresent(array $state, string|\Stringable $log_message = '', bool $check_hash = TRUE, bool $index = TRUE): void;
40
41  /**
42   * Get the past steps.
43   *
44   * @return array
45   *   The past steps.
46   */
47  public function getPast(): array;
48
49  /**
50   * Get the future steps.
51   *
52   * @return array
53   *   The future steps.
54   */
55  public function getFuture(): array;
56
57  /**
58   * Reset history to the current state.
59   */
60  public function clear(): void;
61
62}