Advertisement
sn1ckers

Untitled

Apr 2nd, 2020
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. class SomeService
  5. {
  6. private $entity1Repository;
  7. private $entity2Repository;
  8.  
  9. public function __construct(SomeEntity1Repository $entity1Repository, SomeEntity2Repository $entity2Repository)
  10. {
  11. $this->entity1Repository = $entity1Repository;
  12. $this->entity2Repository = $entity2Repository;
  13. }
  14.  
  15. public function someLogic()
  16. {
  17. $entity1 = $this->entity1Repository->findBySome($some1);
  18. $entity2 = $this->entity2Repository->findBySome($some2);
  19.  
  20. // Внутри add делается ->persist()
  21. $this->entity1Repository->add($entity1);
  22.  
  23. // Внутри add делается ->persist()
  24. $this->entity2Repository->add($entity2);
  25.  
  26. // Как сделать теперь flush ?
  27. // Ведь если flush запихнуть в add, то будет 2 раза flush ?
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement