FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 261 forks source link

expose: false does not work as documented #401

Closed mbessolov closed 2 years ago

mbessolov commented 3 years ago

The documentation page at https://symfony.com/doc/2.x/bundles/FOSJsRoutingBundle/usage.html has the following:

You can prevent to expose a route by configuring it as below:

# app/config/routing.yml
my_very_secret_route:
pattern: /admin
defaults: { _controller: HelloBundle:Admin:index }
options:
expose: false

It does not work anymore the way it is described.

expose: false (or actually any value) now does exactly the same as expose: true thanks to the following:

    public function isRouteExposed(Route $route, $name)
    {
        return true === $route->hasOption('expose') ||
            ('' !== $this->pattern && preg_match('#^' . $this->pattern . '$#', $name));
    }

This problem was introduced in https://github.com/FriendsOfSymfony/FOSJsRoutingBundle/pull/347/files#diff-fab97a6f1291c76154eff6c52009573a80c2cc9b23541d52ff4d229adfb1f0cdR199-L173

I'm not sure if it is a bug, or if it was done intentionally.

I'll be glad to create a PR, please just let me know which way it should be - whether the code, or the documentation should be fixed.

HamzaRouissi commented 3 years ago

hello @mbessolov
for the version 5 of symfony what is the best way to configure FosJSRoiting; there is no documentation for the version 5 thank you !

stof commented 3 years ago

I would say that breaking expose: false was a bug.

stof commented 3 years ago

@elliotalld please don't hijack bug reports to ask off-topic support questions. That's only making it harder to manage issues.

tugrul commented 3 years ago

I couldn't figure out this functionality before. I added test method and fixed the bug.

tobias-93 commented 2 years ago

Fixed in #404