Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c97a98d

Browse filesBrowse files
author
Jules Pietri
committed
[Routing] Exposed "compiler_class" and "utf8" options in configuration
1 parent 6fd6b94 commit c97a98d
Copy full SHA for c97a98d

File tree

Expand file treeCollapse file tree

14 files changed

+216
-1
lines changed
Filter options
Expand file treeCollapse file tree

14 files changed

+216
-1
lines changed

‎src/Symfony/Component/Routing/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ CHANGELOG
1010
* deprecated `generator_base_class`, `generator_cache_class`, `matcher_base_class` and `matcher_cache_class` router options
1111
* deprecated implementing `Serializable` for `Route` and `CompiledRoute`; if you serialize them, please
1212
ensure your unserialization logic can recover from a failure related to an updated serialization format
13+
* exposed `compiler_class` and `utf8` Route options in configuration loaders and configurators
1314

1415
4.2.0
1516
-----

‎src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/Configurator/Traits/RouteTrait.php
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,30 @@ final public function options(array $options)
5757
return $this;
5858
}
5959

60+
/**
61+
* Defines the compiler class used to compiled the Route.
62+
*
63+
* @return $this
64+
*/
65+
final public function compilerClass(string $class)
66+
{
67+
$this->route->addOptions(['compiler_class' => $class]);
68+
69+
return $this;
70+
}
71+
72+
/**
73+
* Whether paths should accept utf8 encoding.
74+
*
75+
* @return $this
76+
*/
77+
final public function utf8(bool $utf8 = true)
78+
{
79+
$this->route->addOptions(['utf8' => $utf8]);
80+
81+
return $this;
82+
}
83+
6084
/**
6185
* Sets the condition.
6286
*

‎src/Symfony/Component/Routing/Loader/XmlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/XmlFileLoader.php
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,12 @@ private function parseConfigs(\DOMElement $node, $path)
311311

312312
$defaults['_controller'] = $controller;
313313
}
314+
if ($node->hasAttribute('compiler-class')) {
315+
$options['compiler_class'] = trim($node->getAttribute('compiler-class'));
316+
}
317+
if ($node->hasAttribute('utf8')) {
318+
$options['utf8'] = XmlUtils::phpize($node->getAttribute('utf8'));
319+
}
314320

315321
return [$defaults, $requirements, $options, $condition, $paths, $prefixes];
316322
}

‎src/Symfony/Component/Routing/Loader/YamlFileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/YamlFileLoader.php
+15-1Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
class YamlFileLoader extends FileLoader
2929
{
3030
private static $availableKeys = [
31-
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root',
31+
'resource', 'type', 'prefix', 'path', 'host', 'schemes', 'methods', 'defaults', 'requirements', 'options', 'condition', 'controller', 'name_prefix', 'trailing_slash_on_root', 'compiler_class', 'utf8',
3232
];
3333
private $yamlParser;
3434

@@ -125,6 +125,13 @@ protected function parseRoute(RouteCollection $collection, $name, array $config,
125125
if (isset($config['controller'])) {
126126
$defaults['_controller'] = $config['controller'];
127127
}
128+
if (isset($config['compiler_class'])) {
129+
$options['compiler_class'] = $config['compiler_class'];
130+
}
131+
if (isset($config['utf8'])) {
132+
$options['utf8'] = $config['utf8'];
133+
}
134+
unset($config['controller'], $config['compiler_class'], $config['utf8']);
128135

129136
if (\is_array($config['path'])) {
130137
$route = new Route('', $defaults, $requirements, $options, $host, $schemes, $methods, $condition);
@@ -166,6 +173,13 @@ protected function parseImport(RouteCollection $collection, array $config, $path
166173
if (isset($config['controller'])) {
167174
$defaults['_controller'] = $config['controller'];
168175
}
176+
if (isset($config['compiler_class'])) {
177+
$options['compiler_class'] = $config['compiler_class'];
178+
}
179+
if (isset($config['utf8'])) {
180+
$options['utf8'] = $config['utf8'];
181+
}
182+
unset($config['controller'], $config['compiler_class'], $config['utf8']);
169183

170184
$this->setCurrentDir(\dirname($path));
171185

‎src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd

Copy file name to clipboardExpand all lines: src/Symfony/Component/Routing/Loader/schema/routing/routing-1.0.xsd
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@
5252
<xsd:attribute name="schemes" type="xsd:string" />
5353
<xsd:attribute name="methods" type="xsd:string" />
5454
<xsd:attribute name="controller" type="xsd:string" />
55+
<xsd:attribute name="compiler-class" type="xsd:string" />
56+
<xsd:attribute name="utf8" type="xsd:boolean" />
5557
</xsd:complexType>
5658

5759
<xsd:complexType name="import">
@@ -68,6 +70,8 @@
6870
<xsd:attribute name="methods" type="xsd:string" />
6971
<xsd:attribute name="controller" type="xsd:string" />
7072
<xsd:attribute name="trailing-slash-on-root" type="xsd:boolean" />
73+
<xsd:attribute name="compiler-class" type="xsd:string" />
74+
<xsd:attribute name="uft8" type="xsd:boolean" />
7175
</xsd:complexType>
7276

7377
<xsd:complexType name="default" mixed="true">
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Loader\Configurator;
4+
5+
use Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler;
6+
7+
return function (RoutingConfigurator $routes) {
8+
$routes
9+
->add('some_route', '/')
10+
->add('custom_compiled_route', '/custom-compilation')->compilerClass(CustomRouteCompiler::class)
11+
;
12+
};
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<routes xmlns="http://symfony.com/schema/routing"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/routing">
5+
6+
<route id="some_route" path="/" />
7+
<route id="custom_compiled_route" path="/custom-compilation" compiler-class="Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler"/>
8+
</routes>
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
some_route:
2+
path: /
3+
4+
custom_compiled_route:
5+
path: /custom-compilation
6+
compiler_class: 'Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler'
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\Routing\Loader\Configurator;
4+
5+
return function (RoutingConfigurator $routes) {
6+
$routes
7+
->add('some_route', '/')
8+
->add('some_utf8_route', '/utf8')->utf8()
9+
;
10+
};
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<routes xmlns="http://symfony.com/schema/routing"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://symfony.com/schema/routing">
5+
6+
<route id="some_route" path="/" />
7+
<route id="some_utf8_route" path="/utf8" utf8="true"/>
8+
</routes>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.