File tree Expand file tree Collapse file tree
src/EventDispatcher/Decorator Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -16,4 +16,4 @@ parameters:
1616 triggered_by : ['php']
1717 show_info : true
1818
19- phpunit : null
19+ # phpunit: null
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ /**
4+ * @author: Julien Mercier-Rojas <julien@jeckel-lab.fr>
5+ * Created at: 30/03/2020
6+ */
7+
8+ declare (strict_types=1 );
9+
10+ namespace JeckelLab \CommandDispatcherBundle \EventDispatcher \Decorator ;
11+
12+ use Doctrine \ORM \EntityManagerInterface ;
13+ use Psr \EventDispatcher \EventDispatcherInterface ;
14+
15+ /**
16+ * Class EntityFlushDecorator
17+ * @package JeckelLab\CommandDispatcherBundle\EventDispatcher\Decorator
18+ */
19+ class EntityFlushDecorator implements EventDispatcherInterface
20+ {
21+ /** @var EventDispatcherInterface */
22+ protected $ next ;
23+
24+ /** @var EntityManagerInterface */
25+ protected $ entityManager ;
26+
27+ /**
28+ * EntityFlushDecorator constructor.
29+ * @param EventDispatcherInterface $next
30+ * @param EntityManagerInterface $entityManager
31+ */
32+ public function __construct (EventDispatcherInterface $ next , EntityManagerInterface $ entityManager )
33+ {
34+ $ this ->next = $ next ;
35+ $ this ->entityManager = $ entityManager ;
36+ }
37+
38+ /**
39+ * @param object $event
40+ * @return object
41+ */
42+ public function dispatch (object $ event ): object
43+ {
44+ $ response = $ this ->next ->dispatch ($ event );
45+
46+ $ this ->entityManager ->flush ();
47+
48+ return $ response ;
49+ }
50+ }
You can’t perform that action at this time.
0 commit comments