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

Add save-method to RelationFactory #2832

Closed
andersbjorkland opened this issue Sep 17, 2021 · 1 comment
Closed

Add save-method to RelationFactory #2832

andersbjorkland opened this issue Sep 17, 2021 · 1 comment

Comments

@andersbjorkland
Copy link

Add a missing save-method to RelationFactory to streamline it with ContentFactory. This method will persist the Relation entity or collection of Relation entities.

@andersbjorkland
Copy link
Author

I'm working on this now. It's almost a carbon copy of ContentFactory->save($content). I'm currently writing some unit tests for it.

There is one change to the class besides adding the save-method. This is the constructor that now will take two arguments:

    public function __construct(RelationRepository $repository, EntityManagerInterface $em)
    {
        $this->em = $em;
        $this->repository = $repository;
        $this->relations = collect([]);
    }

One could argue that $repository is accessible from the EntityManager, but I don't want to affect any other code that uses this constructor. As such, I'm tacking on the EntityManager parameter at the end of the constructor so code that want to use the save-method adds this on creating the RelationFactory (or let dependency injection do it for them).

bobdenotter added a commit that referenced this issue Sep 21, 2021
…-save

Added save-method to RelationFactory. Closes #2832
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