| Conditions | 4 |
| Paths | 4 |
| Total Lines | 21 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function preFlush(PreFlushEventArgs $args) |
||
| 15 | { |
||
| 16 | if (!$this->inRequest) { |
||
| 17 | // let console commands handle flushes anyway they want |
||
| 18 | return; |
||
| 19 | } |
||
| 20 | |||
| 21 | $em = $args->getEntityManager(); |
||
| 22 | if ($em->getConnection()->isTransactionActive()) { |
||
| 23 | // the transaction is managed manually and was already started |
||
| 24 | // probably it won't be handled since it is the end of response |
||
| 25 | // but anyways, it won't cause trouble |
||
| 26 | return; |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($this->flushed) { |
||
| 30 | throw new \BadMethodCallException("The flush can be run only once and is run automatically in the end of each request to prevent data inconsistencies and bad design."); |
||
| 31 | } |
||
| 32 | |||
| 33 | $this->flushed = true; |
||
| 34 | } |
||
| 35 | |||
| 41 |