protected function resolveMiddleware($callback)
    {
        $callbackResolver = $this->callbackResolver;

        return function (Request $request) use ($callback, $callbackResolver) {
            if (!is_string($callback) || substr($callback, 0, 2) !== '::') {
                return $callbackResolver->resolveCallback($callback);
            }

            $controller = $callbackResolver->resolveCallback($request->attributes->get('_controller'));
            if (is_array($controller)) {
                list($cls, $_) = $controller;
            } elseif (is_string($controller)) {
                if (strpos($controller, '::') !== false) {
                    list($cls, $_) = explode('::', $controller);
                } else {
                    $cls = $controller;
                }
            } else {
                return null;
            }
            $callback = [$cls, substr($callback, 2)];

            return $callback;
        };
    }