-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Just a stub for now, I'll try to expand this later.
Bit related: slimphp/Slim#2780
I was trying to do this:
$app->get('/register-platform', [RegisterPlatform::class, 'getRegister'])
->add([RegisterPlatform::class, 'assertValidRegistrationRequest']);assertValidRegistrationRequest is a public (non-static) method with a valid middleware signature:
public function assertValidRegistrationRequest(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterfaceThis however results in a
Uncaught RuntimeException: A middleware must be an object/class name referencing an implementation of MiddlewareInterface or a callable with a matching signature. in /app/vendor/slim/slim/Slim/MiddlewareDispatcher.php:92
My current workaround/solution is:
$app->get('/register-platform', [RegisterPlatform::class, 'getRegister'])
->add($callableResolver->resolve([RegisterPlatform::class, 'assertValidRegistrationRequest']));where $callableResolver is of type DI\Bridge\Slim\CallableResolver. This however feels very verbose.
// or
$app->get('/register-platform', [RegisterPlatform::class, 'getRegister'])
->add(RegisterPlatform::class . '::assertValidRegistrationRequest');but this is ugly.
Is it too extreme to override the MiddlewareDispatcher here to allow these notations? Otherwise the problem needs to be fixed in Slim's MiddlewareDispatcher to defer all middleware notations to the CallableResolver instead of only string variants.
Metadata
Metadata
Assignees
Labels
No labels