Skip to content

Add write support for models#482

Open
BastianLedererIcinga wants to merge 63 commits into
mainfrom
add-write-support
Open

Add write support for models#482
BastianLedererIcinga wants to merge 63 commits into
mainfrom
add-write-support

Conversation

@BastianLedererIcinga

@BastianLedererIcinga BastianLedererIcinga commented May 28, 2026

Copy link
Copy Markdown
Contributor

To support modifying models and then persisting them to the DB, an EntityManager is added, which can save and delete any given Model.
To support this a new Model class is added that serves as parent class for all models in the module, it tracks whether it already exists in the DB, and if what columns have been modified.
Calling on on such a model returns a StatefulQuery, which sets the isNew flag to false on all yielded models, so their state tracking works.

@cla-bot cla-bot Bot added the cla/signed CLA is signed by all contributors of a PR label May 28, 2026
@BastianLedererIcinga BastianLedererIcinga force-pushed the add-write-support branch 2 times, most recently from 56b1dff to 1bbda5e Compare June 8, 2026 08:33
@BastianLedererIcinga BastianLedererIcinga force-pushed the add-write-support branch 3 times, most recently from 71222a7 to 6ce89fd Compare June 16, 2026 06:47
@sukhwinder33445 sukhwinder33445 requested a review from Copilot June 16, 2026 06:54

This comment was marked as resolved.

@BastianLedererIcinga

Copy link
Copy Markdown
Contributor Author

@sukhwinder33445 As discussed the EntitiyManager now supports soft deletes.
I also tried clean up the code related to EntityManger::saveGraph(), I hope it is easier to understand now.

*
* @return $this
*/
public function markDeleted(): static

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it makes sense to rename this to delete(), but that requires a rename of the existing Model\Rotation::delete(), which I wanted to avoid until we agreed that the function is in the right place here.

@sukhwinder33445 sukhwinder33445 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once this is done, I’ll review it further, as it may require changes to other methods.

Comment thread library/Notifications/Common/EntityManager.php
Comment thread library/Notifications/Common/EntityManager.php Outdated
Comment thread library/Notifications/Common/EntityManager.php
Comment thread library/Notifications/Common/EntityManager.php
Comment thread library/Notifications/Common/StatefulQuery.php
Comment thread library/Notifications/Common/EntityManager.php Outdated
Comment thread library/Notifications/Common/EntityManager.php Outdated
Comment thread library/Notifications/Common/EntityManager.php
Comment thread library/Notifications/Common/EntityManager.php Outdated
Comment thread library/Notifications/Common/EntityManager.php Outdated
Comment thread test/php/library/Notifications/Common/EntityManagerTest.php Outdated
Comment thread test/php/library/Notifications/Common/EntityManagerTest.php Outdated
Comment thread test/php/library/Notifications/Common/EntityManagerTest.php Outdated
Comment thread library/Notifications/Common/EntityManager.php Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla/signed CLA is signed by all contributors of a PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants