Part-DB-server/src/Services/LogSystem/EventUndoHelper.php

98 lines
2.8 KiB
PHP
Raw Normal View History

2020-03-01 19:46:48 +01:00
<?php
2022-11-29 21:21:26 +01:00
/*
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
2020-03-15 13:56:31 +01:00
declare(strict_types=1);
2020-03-01 19:46:48 +01:00
/**
* This file is part of Part-DB (https://github.com/Part-DB/Part-DB-symfony).
*
2022-11-29 22:28:53 +01:00
* Copyright (C) 2019 - 2022 Jan Böhmer (https://github.com/jbtronics)
2020-03-01 19:46:48 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
namespace App\Services\LogSystem;
use App\Entity\LogSystem\AbstractLogEntry;
class EventUndoHelper
{
protected ?AbstractLogEntry $undone_event = null;
2023-06-18 21:26:28 +02:00
protected EventUndoMode $mode = EventUndoMode::UNDO;
2020-03-01 19:46:48 +01:00
public function __construct()
{
}
2023-06-18 21:26:28 +02:00
public function setMode(EventUndoMode $mode): void
2020-03-01 19:46:48 +01:00
{
$this->mode = $mode;
}
2023-06-18 21:26:28 +02:00
public function getMode(): EventUndoMode
2020-03-01 19:46:48 +01:00
{
return $this->mode;
}
/**
* Set which event log is currently undone.
* After the flush this message is cleared.
*/
public function setUndoneEvent(?AbstractLogEntry $undone_event): void
{
$this->undone_event = $undone_event;
}
/**
* Returns event that is currently undone.
*/
public function getUndoneEvent(): ?AbstractLogEntry
{
return $this->undone_event;
}
/**
2023-04-15 23:14:53 +02:00
* Clear the currently set undone event.
2020-03-01 19:46:48 +01:00
*/
public function clearUndoneEvent(): void
{
$this->undone_event = null;
}
/**
2023-04-15 23:14:53 +02:00
* Check if an event is undone.
2020-03-01 19:46:48 +01:00
*/
public function isUndo(): bool
{
2020-03-15 13:56:31 +01:00
return $this->undone_event instanceof AbstractLogEntry;
2020-03-01 19:46:48 +01:00
}
2020-03-15 13:56:31 +01:00
}