core icon indicating copy to clipboard operation
core copied to clipboard

feat: separate the persist logic from the back-office controller

Open Deuchnord opened this issue 2 years ago • 3 comments

(Work in progress)

Bolt has an event mechanism that allows developers to get notified and execute code when content or users are getting changes. But these events are currently dispatched by the Bolt\Controller\Backend\ContentEditController controller. As a consequence, developers cannot take advantage of these events in their own code.

In this PR, I propose to create two new data manager classes (one per data type: user and content) that would take care of the task to persist the entities, and dispatch the relevant events. This PR introduces four new events too, {PRE,POST}_PERSIST and {PRE,POST}_FLUSH, so the developers can subscribe to new intermediate states without breaking the backward compatibility.

Deuchnord avatar Aug 19 '21 13:08 Deuchnord

Neat! 👀

ECS is compaining about some Code Style things. These are easily fixed by running make csfix when you're done with this PR. :-)

bobdenotter avatar Aug 19 '21 14:08 bobdenotter

Very cool stuff, @Deuchnord 👏

I-Valchev avatar Aug 23 '21 08:08 I-Valchev

Just need to write tests, and I'll make this RFR.

Deuchnord avatar Aug 23 '21 08:08 Deuchnord