Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #23227 Add support for "controller" keyword for configuring r…
…outes controllers (voronkovich) This PR was merged into the 3.4 branch. Discussion ---------- Add support for "controller" keyword for configuring routes controllers | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT This PR adds a syntax sugar for configuring routes controllers in more user-friendly way by using a `controller` keyword. ```yaml # Current syntax # It looks strange and exposes Symfony's internals blog_show: path: /blog/{slug} defaults: { _controller: AppBundle:Blog:show } # Suggested syntax blog_show: path: /blog/{slug} controller: AppBundle:Blog:show ``` ```xml <?xml version="1.0" encoding="UTF-8" ?> <routes xmlns="http://symfony.com/schema/routing" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <!-- Current syntax --> <route id="blog_list" path="/blog"> <default key="_controller">AppBundle:Blog:list</default> </route> <!-- Suggested syntax --> <route id="blog_list" path="/blog" controller="AppBundle:Blog:list" /> </routes> ``` Commits ------- 06bbee8 [Routing] Use "controller" keyword for configuring routes controllers
- Loading branch information
Showing
16 changed files
with
253 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
src/Symfony/Component/Routing/Tests/Fixtures/controller/import__controller.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing | ||
http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<import resource="routing.xml"> | ||
<default key="_controller">FrameworkBundle:Template:template</default> | ||
</import> | ||
</routes> |
4 changes: 4 additions & 0 deletions
4
src/Symfony/Component/Routing/Tests/Fixtures/controller/import__controller.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
_static: | ||
resource: routing.yml | ||
defaults: | ||
_controller: FrameworkBundle:Template:template |
8 changes: 8 additions & 0 deletions
8
src/Symfony/Component/Routing/Tests/Fixtures/controller/import_controller.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing | ||
http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<import resource="routing.xml" controller="FrameworkBundle:Template:template" /> | ||
</routes> |
3 changes: 3 additions & 0 deletions
3
src/Symfony/Component/Routing/Tests/Fixtures/controller/import_controller.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
_static: | ||
resource: routing.yml | ||
controller: FrameworkBundle:Template:template |
10 changes: 10 additions & 0 deletions
10
src/Symfony/Component/Routing/Tests/Fixtures/controller/import_override_defaults.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing | ||
http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<import resource="routing.xml" controller="FrameworkBundle:Template:template"> | ||
<default key="_controller">AppBundle:Blog:index</default> | ||
</import> | ||
</routes> |
5 changes: 5 additions & 0 deletions
5
src/Symfony/Component/Routing/Tests/Fixtures/controller/import_override_defaults.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
_static: | ||
resource: routing.yml | ||
controller: FrameworkBundle:Template:template | ||
defaults: | ||
_controller: AppBundle:Homepage:show |
10 changes: 10 additions & 0 deletions
10
src/Symfony/Component/Routing/Tests/Fixtures/controller/override_defaults.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing | ||
http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<route id="app_blog" path="/blog" controller="AppBundle:Homepage:show"> | ||
<default key="_controller">AppBundle:Blog:index</default> | ||
</route> | ||
</routes> |
5 changes: 5 additions & 0 deletions
5
src/Symfony/Component/Routing/Tests/Fixtures/controller/override_defaults.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
app_blog: | ||
path: /blog | ||
controller: AppBundle:Homepage:show | ||
defaults: | ||
_controller: AppBundle:Blog:index |
14 changes: 14 additions & 0 deletions
14
src/Symfony/Component/Routing/Tests/Fixtures/controller/routing.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<routes xmlns="http://symfony.com/schema/routing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://symfony.com/schema/routing | ||
http://symfony.com/schema/routing/routing-1.0.xsd"> | ||
|
||
<route id="app_homepage" path="/" controller="AppBundle:Homepage:show" /> | ||
|
||
<route id="app_blog" path="/blog"> | ||
<default key="_controller">AppBundle:Blog:list</default> | ||
</route> | ||
|
||
<route id="app_logout" path="/logout" /> | ||
</routes> |
11 changes: 11 additions & 0 deletions
11
src/Symfony/Component/Routing/Tests/Fixtures/controller/routing.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
app_homepage: | ||
path: / | ||
controller: AppBundle:Homepage:show | ||
|
||
app_blog: | ||
path: /blog | ||
defaults: | ||
_controller: AppBundle:Blog:list | ||
|
||
app_logout: | ||
path: /logout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters