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

Persistence abstraction #29

Open
connors511 opened this issue Apr 20, 2021 · 2 comments
Open

Persistence abstraction #29

connors511 opened this issue Apr 20, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@connors511
Copy link
Contributor

Would you be open to the introduction of a repository to make the persistence of models abstract?

I'm not thinking any massively crazy refactor, but basically just a repository that persists (and fetches) the eloquent models, instead of calling save() directly on the model like here

My motivation for this is

  1. Be able to use an in memory repository in my current project during tests
  2. Have an easy way to hook into loading/saving the models for extra metadata
@ksassnowski
Copy link
Owner

This is something that I considered and eventually decided against when I first created the package. I'm not opposed to the idea in general, but I think it would require quite a few changes. If the Workflow no longer saves itself, it means that the entire control flow needs to change since something outside the workflow needs to pass it to the repository.

The easiest way to do this might be to have the onJobFinished and onJobFailed methods accept a repository as a parameter and then use that instead of $this->save(). This seems like a rather half-hearted implementation, however.

What are your thoughts/plans?

@connors511
Copy link
Contributor Author

I didn't have any concrete plans, but the first (naive) idea that sprung to mind was just pulling it from the container like AbstractWorkflow does, but that's pretty nasty too.

I can dig around some more and try some stuff out.

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

No branches or pull requests

2 participants