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 c82fe60

Browse filesBrowse files
committed
Merge branch '3.3' into 3.4
* 3.3: [Config] Fallback to regular import when glob fails
2 parents 0cfb574 + f7b09e9 commit c82fe60
Copy full SHA for c82fe60

File tree

2 files changed

+15
-8
lines changed
Filter options

2 files changed

+15
-8
lines changed

‎src/Symfony/Component/Config/Loader/FileLoader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Loader/FileLoader.php
+7-8Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,17 @@ public function getLocator()
8383
*/
8484
public function import($resource, $type = null, $ignoreErrors = false, $sourceResource = null)
8585
{
86-
$ret = array();
87-
$ct = 0;
88-
if (!is_string($resource) || false === strpbrk($resource, '*?{[')) {
89-
$ret[] = $this->doImport($resource, $type, $ignoreErrors, $sourceResource);
90-
} else {
91-
foreach ($this->glob($resource, false, $_, $ignoreErrors) as $path => $info) {
92-
++$ct;
86+
if (is_string($resource) && false !== strpbrk($resource, '*?{[')) {
87+
$ret = array();
88+
foreach ($this->glob($resource, false, $_, true) as $path => $info) {
9389
$ret[] = $this->doImport($path, $type, $ignoreErrors, $sourceResource);
9490
}
91+
if ($ret) {
92+
return count($ret) > 1 ? $ret : $ret[0];
93+
}
9594
}
9695

97-
return $ct > 1 ? $ret : (isset($ret[0]) ? $ret[0] : null);
96+
return $this->doImport($resource, $type, $ignoreErrors, $sourceResource);
9897
}
9998

10099
/**

‎src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Config/Tests/Loader/FileLoaderTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,14 @@ public function testImportWithFileLocatorDelegation()
6666
$this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderImportCircularReferenceException', $e, '->import() throws a FileLoaderImportCircularReferenceException if the resource is already loading');
6767
}
6868
}
69+
70+
public function testImportWithGlobLikeResource()
71+
{
72+
$locatorMock = $this->getMockBuilder('Symfony\Component\Config\FileLocatorInterface')->getMock();
73+
$loader = new TestFileLoader($locatorMock);
74+
75+
$this->assertSame('[foo]', $loader->import('[foo]'));
76+
}
6977
}
7078

7179
class TestFileLoader extends FileLoader

0 commit comments

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