def url_for(endpoint_or_url_or_config_key: str,
            _anchor: Optional[str] = None,
            _cls: Optional[Union[object, type]] = None,
            _external: Optional[bool] = False,
            _external_host: Optional[str] = None,
            _method: Optional[str] = None,
            _scheme: Optional[str] = None,
            **values,
            ) -> Union[str, None]:
    what = endpoint_or_url_or_config_key
    if what and what.isupper():
        what = current_app.config.get(what)
    if isinstance(what, LocalProxy):
        what = what._get_current_object()
    if not what or '/' in what:
        return what
    flask_url_for_kwargs = dict(_anchor=_anchor, _external=_external,
                                _external_host=_external_host, _method=_method,
                                _scheme=_scheme, **values)
    if _cls and '.' not in what:
        controller_routes = getattr(_cls, CONTROLLER_ROUTES_ATTR)
        method_routes = controller_routes.get(what)
        try:
            return _url_for(method_routes[0].endpoint, **flask_url_for_kwargs)
        except (
            BuildError,
            IndexError,
            TypeError,
        ):
            pass
    return _url_for(what, **flask_url_for_kwargs)