mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-02-13 21:19:36 +00:00
Use enum for undo mode
This commit is contained in:
parent
218b0adb8f
commit
8a20584e27
14 changed files with 140 additions and 180 deletions
|
|
@ -46,27 +46,19 @@ use InvalidArgumentException;
|
|||
|
||||
class EventUndoHelper
|
||||
{
|
||||
final public const MODE_UNDO = 'undo';
|
||||
final public const MODE_REVERT = 'revert';
|
||||
|
||||
protected const ALLOWED_MODES = [self::MODE_REVERT, self::MODE_UNDO];
|
||||
|
||||
protected ?AbstractLogEntry $undone_event = null;
|
||||
protected string $mode = self::MODE_UNDO;
|
||||
protected EventUndoMode $mode = EventUndoMode::UNDO;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function setMode(string $mode): void
|
||||
public function setMode(EventUndoMode $mode): void
|
||||
{
|
||||
if (!in_array($mode, self::ALLOWED_MODES, true)) {
|
||||
throw new InvalidArgumentException('Invalid mode passed!');
|
||||
}
|
||||
$this->mode = $mode;
|
||||
}
|
||||
|
||||
public function getMode(): string
|
||||
public function getMode(): EventUndoMode
|
||||
{
|
||||
return $this->mode;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue