Conditions | 3 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
51 | public function transactional($func) |
||
52 | { |
||
53 | if (!is_callable($func)) { |
||
54 | throw new \InvalidArgumentException('Expected argument of type "callable", got "' . gettype($func) . '"'); |
||
55 | } |
||
56 | |||
57 | $this->beginTransaction(); |
||
58 | |||
59 | try { |
||
60 | $return = call_user_func($func, $this); |
||
61 | |||
62 | $this->commitTransaction(); |
||
63 | |||
64 | return $return; |
||
65 | } catch (\Exception $e) { |
||
66 | $this->entityManager->close(); |
||
67 | $this->rollbackTransaction(); |
||
68 | |||
69 | throw $e; |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 |