Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Loggable] Add option to store prev data #2770

Open
zorn-v opened this issue Feb 17, 2024 · 0 comments
Open

[Loggable] Add option to store prev data #2770

zorn-v opened this issue Feb 17, 2024 · 0 comments

Comments

@zorn-v
Copy link

zorn-v commented Feb 17, 2024

Feature Request

It may be useful to simplify "revert", especially if older logs is purged time by time.
Also just for show information like "field changed from PREV_VALUE to VALUE" in some log viewer.
And maybe store full entry on delete (like alternative to softdeletable)

How it can be implemented

Maybe some check in LoggableListener::createLogEntry like

if (method_exists($logEntry, 'setPrevData')) {
    $prevData = [];
    foreach ($ea->getObjectChangeSet($uow, $object) as $field => $changes) {
        $prevData =  $changes[0];
        // some checks, processings etc.
        $prevData[$field] = $prevData;
    }
    $logEntry->setPrevData($prevData);
}

Maybe add prev_data field/method to default log entry in future and add option to Loggable annotation/attribute

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant