Skip to content

Commit ca780c8

Browse files
Merge branch '3.4' into 4.0
* 3.4: (24 commits) moved Twig runtime to proper class fixed deprecated messages in tests add PHP errors options to XML schema definition [HttpCache] Unlink tmp file on error Added LB translation for #26327 (Errors sign for people that do not see colors) [TwigBridge] Fix rendering of currency by MoneyType Import InvalidArgumentException in PdoAdapter [DI] Do not suggest writing an implementation when multiple exist [Intl] Update ICU data to 61.1 Use 3rd person verb form in command description [Validator] Add Japanese translation Support phpdbg SAPI in Debug::enable() [HttpKernel] DumpDataCollector: do not flush when a dumper is provided [DI] Fix hardcoded cache dir for warmups [Routing] fix tests [Routing] Fixed the importing of files using glob patterns that match multiple resources [Ldap] cast to string when checking empty passwords [Validator] sync validator translation id [WebProfilerBundle] use the router to resolve file links no type errors with invalid submitted data types ...
2 parents 1bfe572 + 5f90733 commit ca780c8

18 files changed

+196
-40
lines changed

Loader/Configurator/RoutingConfigurator.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,17 @@ public function __construct(RouteCollection $collection, PhpFileLoader $loader,
3939
final public function import($resource, $type = null, $ignoreErrors = false)
4040
{
4141
$this->loader->setCurrentDir(dirname($this->path));
42-
$subCollection = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
42+
$imported = $this->loader->import($resource, $type, $ignoreErrors, $this->file);
43+
if (!is_array($imported)) {
44+
return new ImportConfigurator($this->collection, $imported);
45+
}
4346

44-
return new ImportConfigurator($this->collection, $subCollection);
47+
$mergedCollection = new RouteCollection();
48+
foreach ($imported as $subCollection) {
49+
$mergedCollection->addCollection($subCollection);
50+
}
51+
52+
return new ImportConfigurator($this->collection, $mergedCollection);
4553
}
4654

4755
/**

Loader/XmlFileLoader.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,26 +146,33 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
146146

147147
$this->setCurrentDir(dirname($path));
148148

149-
$subCollection = $this->import($resource, ('' !== $type ? $type : null), false, $file);
150-
/* @var $subCollection RouteCollection */
151-
$subCollection->addPrefix($prefix);
152-
if (null !== $host) {
153-
$subCollection->setHost($host);
154-
}
155-
if (null !== $condition) {
156-
$subCollection->setCondition($condition);
157-
}
158-
if (null !== $schemes) {
159-
$subCollection->setSchemes($schemes);
160-
}
161-
if (null !== $methods) {
162-
$subCollection->setMethods($methods);
149+
$imported = $this->import($resource, ('' !== $type ? $type : null), false, $file);
150+
151+
if (!is_array($imported)) {
152+
$imported = array($imported);
163153
}
164-
$subCollection->addDefaults($defaults);
165-
$subCollection->addRequirements($requirements);
166-
$subCollection->addOptions($options);
167154

168-
$collection->addCollection($subCollection);
155+
foreach ($imported as $subCollection) {
156+
/* @var $subCollection RouteCollection */
157+
$subCollection->addPrefix($prefix);
158+
if (null !== $host) {
159+
$subCollection->setHost($host);
160+
}
161+
if (null !== $condition) {
162+
$subCollection->setCondition($condition);
163+
}
164+
if (null !== $schemes) {
165+
$subCollection->setSchemes($schemes);
166+
}
167+
if (null !== $methods) {
168+
$subCollection->setMethods($methods);
169+
}
170+
$subCollection->addDefaults($defaults);
171+
$subCollection->addRequirements($requirements);
172+
$subCollection->addOptions($options);
173+
174+
$collection->addCollection($subCollection);
175+
}
169176
}
170177

171178
/**

Loader/YamlFileLoader.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,26 +150,33 @@ protected function parseImport(RouteCollection $collection, array $config, $path
150150

151151
$this->setCurrentDir(dirname($path));
152152

153-
$subCollection = $this->import($config['resource'], $type, false, $file);
154-
/* @var $subCollection RouteCollection */
155-
$subCollection->addPrefix($prefix);
156-
if (null !== $host) {
157-
$subCollection->setHost($host);
158-
}
159-
if (null !== $condition) {
160-
$subCollection->setCondition($condition);
161-
}
162-
if (null !== $schemes) {
163-
$subCollection->setSchemes($schemes);
164-
}
165-
if (null !== $methods) {
166-
$subCollection->setMethods($methods);
153+
$imported = $this->import($config['resource'], $type, false, $file);
154+
155+
if (!is_array($imported)) {
156+
$imported = array($imported);
167157
}
168-
$subCollection->addDefaults($defaults);
169-
$subCollection->addRequirements($requirements);
170-
$subCollection->addOptions($options);
171158

172-
$collection->addCollection($subCollection);
159+
foreach ($imported as $subCollection) {
160+
/* @var $subCollection RouteCollection */
161+
$subCollection->addPrefix($prefix);
162+
if (null !== $host) {
163+
$subCollection->setHost($host);
164+
}
165+
if (null !== $condition) {
166+
$subCollection->setCondition($condition);
167+
}
168+
if (null !== $schemes) {
169+
$subCollection->setSchemes($schemes);
170+
}
171+
if (null !== $methods) {
172+
$subCollection->setMethods($methods);
173+
}
174+
$subCollection->addDefaults($defaults);
175+
$subCollection->addRequirements($requirements);
176+
$subCollection->addOptions($options);
177+
178+
$collection->addCollection($subCollection);
179+
}
173180
}
174181

175182
/**

Router.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ function (ConfigCacheInterface $cache) {
302302
}
303303
);
304304

305-
require_once $cache->getPath();
305+
if (!class_exists($this->options['matcher_cache_class'], false)) {
306+
require_once $cache->getPath();
307+
}
306308

307309
return $this->matcher = new $this->options['matcher_cache_class']($this->context);
308310
}
@@ -334,7 +336,9 @@ function (ConfigCacheInterface $cache) {
334336
}
335337
);
336338

337-
require_once $cache->getPath();
339+
if (!class_exists($this->options['generator_cache_class'], false)) {
340+
require_once $cache->getPath();
341+
}
338342

339343
$this->generator = new $this->options['generator_cache_class']($this->context, $this->logger);
340344
}

Tests/Fixtures/glob/bar.xml

Lines 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+
http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="bar_route" path="/bar" controller="AppBundle:Bar:view" />
8+
</routes>

Tests/Fixtures/glob/bar.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bar_route:
2+
path: /bar
3+
defaults:
4+
_controller: AppBundle:Bar:view

Tests/Fixtures/glob/baz.xml

Lines 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+
http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<route id="baz_route" path="/baz" controller="AppBundle:Baz:view" />
8+
</routes>

Tests/Fixtures/glob/baz.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
baz_route:
2+
path: /baz
3+
defaults:
4+
_controller: AppBundle:Baz:view
Lines 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+
http://symfony.com/schema/routing/routing-1.0.xsd">
6+
7+
<import resource="ba?.xml" />
8+
</routes>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_static:
2+
resource: ba?.yml

0 commit comments

Comments
 (0)