66
77use Psr \Container \ContainerInterface ;
88use Yiisoft \Injector \Injector ;
9+ use Yiisoft \Queue \Message \MessageInterface ;
910use Yiisoft \Queue \Middleware \InvalidMiddlewareDefinitionException ;
1011use Yiisoft \Queue \Middleware \MiddlewareFactory ;
1112
@@ -22,16 +23,16 @@ final class MiddlewareFactoryPush extends MiddlewareFactory implements Middlewar
2223 *
2324 * - A middleware object.
2425 * - A name of a middleware class. The middleware instance will be obtained from container and executed.
25- * - A callable with `function(ServerRequestInterface $request, RequestHandlerInterface $handler):
26- * ResponseInterface ` signature.
26+ * - A callable with `function(MessageInterface $message, MessageHandlerPushInterface $handler):
27+ * MessageInterface ` signature.
2728 * - A controller handler action in format `[TestController::class, 'index']`. `TestController` instance will
2829 * be created and `index()` method will be executed.
2930 * - A function returning a middleware. The middleware returned will be executed.
3031 *
3132 * For handler action and callable
3233 * typed parameters are automatically injected using dependency injection container.
33- * Current request and handler could be obtained by type-hinting for {@see ServerRequestInterface }
34- * and {@see RequestHandlerInterface }.
34+ * Current message and handler could be obtained by type-hinting for {@see MessageInterface }
35+ * and {@see MessageHandlerPushInterface }.
3536 *
3637 * @throws InvalidMiddlewareDefinitionException
3738 *
@@ -70,15 +71,15 @@ public function __construct(
7071 $ this ->callback = $ callback ;
7172 }
7273
73- public function processPush (PushRequest $ request , MessageHandlerPushInterface $ handler ): PushRequest
74+ public function processPush (MessageInterface $ message , MessageHandlerPushInterface $ handler ): MessageInterface
7475 {
75- $ response = (new Injector ($ this ->container ))->invoke ($ this ->callback , [$ request , $ handler ]);
76- if ($ response instanceof PushRequest ) {
76+ $ response = (new Injector ($ this ->container ))->invoke ($ this ->callback , [$ message , $ handler ]);
77+ if ($ response instanceof MessageInterface ) {
7778 return $ response ;
7879 }
7980
8081 if ($ response instanceof MiddlewarePushInterface) {
81- return $ response ->processPush ($ request , $ handler );
82+ return $ response ->processPush ($ message , $ handler );
8283 }
8384
8485 throw new InvalidMiddlewareDefinitionException ($ this ->callback );
0 commit comments