File tree Expand file tree Collapse file tree 5 files changed +14
-103
lines changed Expand file tree Collapse file tree 5 files changed +14
-103
lines changed Original file line number Diff line number Diff line change 33namespace Enqueue \AsyncEventDispatcher ;
44
55use Symfony \Component \EventDispatcher \Event ;
6- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
76
8- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
7+ if (class_exists (Event::class)) {
98 /**
10- * Symfony < 4.3.
11- */
12- class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
13- {
14- /**
15- * {@inheritdoc}
16- */
17- public function dispatch ($ eventName , Event $ event = null )
18- {
19- $ this ->parentDispatch ($ event , $ eventName );
20-
21- $ this ->trueEventDispatcher ->dispatch ($ eventName , $ event );
22- }
23-
24- protected function parentDispatch ($ event , $ eventName )
25- {
26- parent ::dispatch ($ eventName , $ event );
27- }
28- }
29- } elseif (class_exists (Event::class)) {
30- /**
31- * Symfony >= 4.3 and < 5.0.
9+ * Symfony < 5.0.
3210 */
3311 class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
3412 {
Original file line number Diff line number Diff line change 33namespace Enqueue \AsyncEventDispatcher ;
44
55use Symfony \Component \EventDispatcher \Event ;
6- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
76use Symfony \Contracts \EventDispatcher \Event as ContractEvent ;
87
9- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
8+ if (class_exists (Event::class)) {
109 /**
11- * Symfony < 4.3.
12- */
13- class AsyncListener extends AbstractAsyncListener
14- {
15- public function __invoke (Event $ event , $ eventName )
16- {
17- $ this ->onEvent ($ event , $ eventName );
18- }
19-
20- /**
21- * @param string $eventName
22- */
23- public function onEvent (Event $ event , $ eventName )
24- {
25- if (false == isset ($ this ->syncMode [$ eventName ])) {
26- $ transformerName = $ this ->registry ->getTransformerNameForEvent ($ eventName );
27-
28- $ message = $ this ->registry ->getTransformer ($ transformerName )->toMessage ($ eventName , $ event );
29- $ message ->setProperty ('event_name ' , $ eventName );
30- $ message ->setProperty ('transformer_name ' , $ transformerName );
31-
32- $ this ->context ->createProducer ()->send ($ this ->eventQueue , $ message );
33- }
34- }
35- }
36- } elseif (class_exists (Event::class)) {
37- /**
38- * Symfony >= 4.3 and < 5.0.
10+ * Symfony < 5.0.
3911 */
4012 class AsyncListener extends AbstractAsyncListener
4113 {
Original file line number Diff line number Diff line change 44
55use Interop \Queue \Message ;
66use Symfony \Component \EventDispatcher \Event ;
7- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
87use Symfony \Contracts \EventDispatcher \Event as ContractEvent ;
98
10- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
9+ if (class_exists (Event::class)) {
1110 /**
12- * Symfony < 4.3.
13- */
14- interface EventTransformer
15- {
16- /**
17- * @param string $eventName
18- *
19- * @return Message
20- */
21- public function toMessage ($ eventName , Event $ event = null );
22-
23- /**
24- * If you able to transform message back to event return it.
25- * If you failed to transform for some reason you can return a string status.
26- *
27- * @param mixed $eventName
28- *
29- * @return Event|string|object
30- *
31- * @see Process constants) or an object that implements __toString method.
32- * The object must have a __toString method is supposed to be used as Processor::process return value.
33- */
34- public function toEvent ($ eventName , Message $ message );
35- }
36- } elseif (class_exists (Event::class)) {
37- /**
38- * Symfony >= 4.3 and < 5.0.
11+ * Symfony < 5.0.
3912 */
4013 interface EventTransformer
4114 {
Original file line number Diff line number Diff line change 33namespace Enqueue \AsyncEventDispatcher ;
44
55use Symfony \Component \EventDispatcher \Event ;
6- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
76use Symfony \Contracts \EventDispatcher \Event as ContractEvent ;
87
9- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
8+ if (class_exists (Event::class)) {
109 /**
11- * Symfony < 4.3.
12- */
13- class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
14- {
15- public function toMessage ($ eventName , Event $ event = null )
16- {
17- return $ this ->context ->createMessage (serialize ($ event ));
18- }
19- }
20- } elseif (class_exists (Event::class)) {
21- /**
22- * Symfony >= 4.3 and < 5.0.
10+ * Symfony < 5.0.
2311 */
2412 class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
2513 {
Original file line number Diff line number Diff line change 99 "php" : " ^7.1.3" ,
1010 "enqueue/enqueue" : " ^0.9" ,
1111 "queue-interop/queue-interop" : " ^0.7|^0.8" ,
12- "symfony/event-dispatcher" : " ^3.4|^4 |^5"
12+ "symfony/event-dispatcher" : " ^4.3 |^5"
1313 },
1414 "require-dev" : {
1515 "phpunit/phpunit" : " ~7.5" ,
16- "symfony/dependency-injection" : " ^3.4|^4 |^5" ,
17- "symfony/config" : " ^3.4|^4 |^5" ,
18- "symfony/http-kernel" : " ^3.4|^4 |^5" ,
19- "symfony/filesystem" : " ^3.4|^4 |^5" ,
20- "symfony/yaml" : " ^3.4|^4 |^5" ,
16+ "symfony/dependency-injection" : " ^4.3 |^5" ,
17+ "symfony/config" : " ^4.3 |^5" ,
18+ "symfony/http-kernel" : " ^4.3 |^5" ,
19+ "symfony/filesystem" : " ^4.3 |^5" ,
20+ "symfony/yaml" : " ^4.3 |^5" ,
2121 "enqueue/null" : " 0.9.x-dev" ,
2222 "enqueue/fs" : " 0.9.x-dev" ,
2323 "enqueue/test" : " 0.9.x-dev"
You can’t perform that action at this time.
0 commit comments