Skip to content

Instantly share code, notes, and snippets.

@HeahDude
Created July 17, 2018 11:00
Show Gist options
  • Save HeahDude/bda5b60e44043ca892feda3b1b1e4eeb to your computer and use it in GitHub Desktop.
Save HeahDude/bda5b60e44043ca892feda3b1b1e4eeb to your computer and use it in GitHub Desktop.
author: heah
questions:
- question: |
What will be the result of the following code?
```yaml
// config/routes.yaml
some_route:
path: /some-path/{param}
controller: 'Some\Controller::action'
defaults:
param: 'TOTO'
```
```php
echo $urlGenerator->generate('some_route');
```
answers:
- KO "/some-path/TOTO"
- KO "/some-path/"
- OK "/some-path"
component: Symfony - Routing
extra_link: http://symfony.com/doc/current/routing.html#giving-placeholders-a-default-value
- question: |
What will be the result of the following code?
```yaml
// config/routes.yaml
some_route:
path: /some-path/{param}
controller: 'Some\Controller::action'
defaults:
param: 'TOTO'
```
```php
echo $urlGenerator->generate('some_route', ['toto' => 'param']);
```
answers:
- KO "/some-path"
- OK "/some-path?toto=param"
- KO an exception because "toto" is not a valid parameter
component: Symfony - Routing
extra_link: http://symfony.com/doc/current/routing.html#generating-urls-with-query-strings
- question: |
What will be the result of the following code?
```yaml
// config/routes.yaml
some_route:
path: /{param}/some-path
controller: 'Some\Controller::action'
defaults:
param: 'TOTO'
```
```php
echo $urlGenerator->generate('some_route');
```
answers:
- KO "/TOTO/some-path"
- OK "/some-path"
- KO an exception because an optional param must be at the end of the path
component: Symfony - Routing
extra_link: http://symfony.com/doc/current/routing.html#generating-urls-with-query-strings
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment