Skip to content
This repository was archived by the owner on Feb 22, 2019. It is now read-only.

Commit 9e3a71c

Browse files
committed
Allow route.name to be a string in Configuration
1 parent 3956397 commit 9e3a71c

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

.gush.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ table-pr:
66
deprecations: [Deprecations, 'no']
77
fixed_tickets: ['Fixed Tickets', '']
88
license: [License, MIT]
9+
pr_type:
10+
- feature
11+
- bug
12+
- refactor
13+
- style
14+
- doc
15+
- security
916
repo_adapter: github
1017
issue_tracker: github
1118
repo_org: rollerworks

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ rollerworks_navigation:
8282
label: ~ # Label of the menu-item, this will be translated with the translator_domain
8383
translator_domain: Menus # translator domain for the label
8484
route: { name: ~, parameters: { } } # The route.name can not be empty, parameters is optional
85+
# route can also be only a string (route name)
8586
uri: ~ # Alternatively you can use a URI instead of a route
8687
items: [] # Sub-level items, same as this example (unlimited depth nesting)
8788

@@ -140,6 +141,7 @@ rollerworks_navigation:
140141
label: ~ # Label of the breadcrumb, this will be translated with the translator_domain
141142
translator_domain: Breadcrumbs # translator domain for the label
142143
route: { name: ~, parameters: { } } # The route.name can not be empty, parameters is optional
144+
# route can also be only a string (route name)
143145
uri: ~ # Alternatively you can use a URI instead of a route
144146
145147
# If your breadcrumb is to dynamic you may also use a dedicated service.

src/DependencyInjection/Configuration.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,14 @@ public function getConfigTreeBuilder()
6767
->scalarNode('translator_domain')->defaultValue('Breadcrumbs')->end()
6868
->scalarNode('uri')->defaultNull()->end()
6969
->arrayNode('route')
70+
->beforeNormalization()
71+
->ifString()
72+
->then(
73+
function ($v) {
74+
return array('name' => $v);
75+
}
76+
)
77+
->end()
7078
->children()
7179
->scalarNode('name')->cannotBeEmpty()->end()
7280
->booleanNode('absolute')->defaultFalse()->end()
@@ -107,6 +115,14 @@ final public function addItemConfig(ArrayNodeDefinition $rootNode)
107115
->scalarNode('translator_domain')->defaultValue('Menus')->end()
108116
->scalarNode('uri')->defaultNull()->end()
109117
->arrayNode('route')
118+
->beforeNormalization()
119+
->ifString()
120+
->then(
121+
function ($v) {
122+
return array('name' => $v);
123+
}
124+
)
125+
->end()
110126
->children()
111127
->scalarNode('name')->cannotBeEmpty()->end()
112128
->booleanNode('absolute')->defaultFalse()->end()

tests/DependencyInjection/ConfigurationTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,44 @@ public function testBreadcrumbsWithDefaulted()
5252
);
5353
}
5454

55+
public function testBreadcrumbWithRouteNodeAsString()
56+
{
57+
$this->assertProcessedConfigurationEquals(
58+
array(
59+
array(
60+
'breadcrumbs' => array(
61+
'customers' => array(
62+
'parent' => null,
63+
'label' => null,
64+
'options' => array(),
65+
'translator_domain' => 'Breadcrumbs',
66+
'route' => 'app_homepage',
67+
'expression' => null,
68+
),
69+
),
70+
),
71+
),
72+
array(
73+
'menus' => array(),
74+
'breadcrumbs' => array(
75+
'customers' => array(
76+
'parent' => null,
77+
'label' => null,
78+
'options' => array(),
79+
'translator_domain' => 'Breadcrumbs',
80+
'route' => array(
81+
'name' => 'app_homepage',
82+
'absolute' => false,
83+
'parameters' => array(),
84+
),
85+
'uri' => null,
86+
'expression' => null,
87+
),
88+
),
89+
)
90+
);
91+
}
92+
5593
public function testBreadcrumbAcceptsService()
5694
{
5795
$this->assertProcessedConfigurationEquals(

0 commit comments

Comments
 (0)