Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
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;
6
7use Drupal\Component\Render\FormattableMarkup;
8
9/**
10 * History interface.
11 *
12 * When you implement Undo and Redo, you want to keep track of the history
13 * of this state at different points in time.
14 *
15 * Inspired from https://redux.js.org/usage/implementing-undo-history
16 */
17interface HistoryInterface {
18
19  /**
20   * Get current step.
21   *
22   * @return \Drupal\display_builder\HistoryStep|null
23   *   The current data.
24   */
25  public function getCurrent(): ?HistoryStep;
26
27  /**
28   * Get the state of the current step.
29   *
30   * @return array
31   *   The current state.
32   */
33  public function getCurrentState(): array;
34
35  /**
36   * Set a new present.
37   *
38   * @param array $state
39   *   The state to set.
40   * @param string|\Drupal\Component\Render\FormattableMarkup $log_message
41   *   (Optional) The log message.
42   * @param bool $check_hash
43   *   (Optional) Should check hash to avoid duplicates. Default to TRUE.
44   */
45  public function setNewPresent(array $state, FormattableMarkup|string $log_message = '', bool $check_hash = TRUE): void;
46
47  /**
48   * Get number of past logs.
49   *
50   * @return int
51   *   The number of past logs.
52   */
53  public function getCountPast(): int;
54
55  /**
56   * Get number of future logs.
57   *
58   * @return int
59   *   The number of future logs.
60   */
61  public function getCountFuture(): int;
62
63  /**
64   * Move history to the last past state.
65   */
66  public function undo(): void;
67
68  /**
69   * Move history to the first future state.
70   */
71  public function redo(): void;
72
73  /**
74   * Reset history to the current state.
75   */
76  public function clear(): void;
77
78}