Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support boolean parameters in Route condition #30366

Closed
quazardous opened this Issue Feb 24, 2019 · 3 comments

Comments

Projects
None yet
6 participants
@quazardous
Copy link

quazardous commented Feb 24, 2019

Description

Using parameter substitution with boolean is not allowed in route condition.

Example

So this is not possible:

/**
 * @Route("/test", condition="%kernel.debug%")
 */
class TestController extends AbstractController
{*
...

Exception is here :

// symfony/framework-bundle/Routing/Router.php
// near line 176 : hard coded type test : add is_bool() ?
...

            if (\is_string($resolved) || is_numeric($resolved)) {
                $this->collectedParameters[$match[1]] = $resolved;

                return (string) $resolved;
            }
...
@nicolas-grekas

This comment has been minimized.

Copy link
Member

nicolas-grekas commented Feb 24, 2019

Would you like to send a PR doing so? I'd suggest casting booleans to the "0"/"1" string.
That should target master as it's a new feature and it should come with test cases of course ;)

@quazardous

This comment has been minimized.

Copy link
Author

quazardous commented Feb 24, 2019

I'll give it a shot but not in the next couple of weeks. Too much on my plate 😅

@dmaicher

This comment has been minimized.

Copy link
Contributor

dmaicher commented Feb 25, 2019

See #30379

@fabpot fabpot closed this Mar 4, 2019

symfony-splitter pushed a commit to symfony/framework-bundle that referenced this issue Mar 4, 2019

feature #30379 [FrameworkBundle][Routing] allow boolean container par…
…ameters for routes (dmaicher)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[FrameworkBundle][Routing] allow boolean container parameters for routes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30366
| License       | MIT
| Doc PR        | symfony/symfony-docs#11059

This fixes symfony/symfony#30366 and adds support for boolean container parameters in route conditions, defaults etc.

Commits
-------

21f4e38800 [FrameworkBundle][Routing] allow boolean container parameters for routes

fabpot added a commit that referenced this issue Mar 4, 2019

feature #30379 [FrameworkBundle][Routing] allow boolean container par…
…ameters for routes (dmaicher)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[FrameworkBundle][Routing] allow boolean container parameters for routes

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #30366
| License       | MIT
| Doc PR        | symfony/symfony-docs#11059

This fixes #30366 and adds support for boolean container parameters in route conditions, defaults etc.

Commits
-------

21f4e38 [FrameworkBundle][Routing] allow boolean container parameters for routes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.