File tree 5 files changed +14
-103
lines changed
5 files changed +14
-103
lines changed Original file line number Diff line number Diff line change 3
3
namespace Enqueue \AsyncEventDispatcher ;
4
4
5
5
use Symfony \Component \EventDispatcher \Event ;
6
- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
7
6
8
- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
7
+ if (class_exists (Event::class)) {
9
8
/**
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.
32
10
*/
33
11
class AsyncEventDispatcher extends AbstractAsyncEventDispatcher
34
12
{
Original file line number Diff line number Diff line change 3
3
namespace Enqueue \AsyncEventDispatcher ;
4
4
5
5
use Symfony \Component \EventDispatcher \Event ;
6
- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
7
6
use Symfony \Contracts \EventDispatcher \Event as ContractEvent ;
8
7
9
- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
8
+ if (class_exists (Event::class)) {
10
9
/**
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.
39
11
*/
40
12
class AsyncListener extends AbstractAsyncListener
41
13
{
Original file line number Diff line number Diff line change 4
4
5
5
use Interop \Queue \Message ;
6
6
use Symfony \Component \EventDispatcher \Event ;
7
- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
8
7
use Symfony \Contracts \EventDispatcher \Event as ContractEvent ;
9
8
10
- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
9
+ if (class_exists (Event::class)) {
11
10
/**
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.
39
12
*/
40
13
interface EventTransformer
41
14
{
Original file line number Diff line number Diff line change 3
3
namespace Enqueue \AsyncEventDispatcher ;
4
4
5
5
use Symfony \Component \EventDispatcher \Event ;
6
- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
7
6
use Symfony \Contracts \EventDispatcher \Event as ContractEvent ;
8
7
9
- if (class_exists (Event::class) && ! class_exists (LegacyEventDispatcherProxy::class) ) {
8
+ if (class_exists (Event::class)) {
10
9
/**
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.
23
11
*/
24
12
class PhpSerializerEventTransformer extends AbstractPhpSerializerEventTransformer implements EventTransformer
25
13
{
Original file line number Diff line number Diff line change 9
9
"php" : " ^7.1.3" ,
10
10
"enqueue/enqueue" : " ^0.9" ,
11
11
"queue-interop/queue-interop" : " ^0.7|^0.8" ,
12
- "symfony/event-dispatcher" : " ^3.4|^4 |^5"
12
+ "symfony/event-dispatcher" : " ^4.3 |^5"
13
13
},
14
14
"require-dev" : {
15
15
"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" ,
21
21
"enqueue/null" : " 0.9.x-dev" ,
22
22
"enqueue/fs" : " 0.9.x-dev" ,
23
23
"enqueue/test" : " 0.9.x-dev"
You can’t perform that action at this time.
0 commit comments