Skip to content

Commit 4d19cc2

Browse files
Added CHANGELOG entries, cleanups
1 parent 02f589b commit 4d19cc2

File tree

3 files changed

+9
-14
lines changed

3 files changed

+9
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
2.8.0
5+
-----
6+
7+
* allowed specifying a directory to recursively load all configuration files it contains
8+
49
2.7.0
510
-----
611

Loader/DirectoryLoader.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Symfony\Component\Config\Resource\DirectoryResource;
1515

1616
/**
17-
* DirectoryLoader is a recursive loader to go through directories
17+
* DirectoryLoader is a recursive loader to go through directories.
1818
*
1919
* @author Sebastien Lavoie <seb@wemakecustom.com>
2020
*/
@@ -30,7 +30,7 @@ public function load($file, $type = null)
3030
$this->container->addResource(new DirectoryResource($path));
3131

3232
foreach (scandir($path) as $dir) {
33-
if ($dir[0] !== '.') {
33+
if ('.' !== $dir[0]) {
3434
if (is_dir($path.'/'.$dir)) {
3535
$dir .= '/'; // append / to allow recursion
3636
}
@@ -51,10 +51,6 @@ public function supports($resource, $type = null)
5151
return true;
5252
}
5353

54-
if (null === $type) {
55-
return preg_match('/\/$/', $resource) === 1;
56-
}
57-
58-
return false;
54+
return null === $type && is_string($resource) && '/' === substr($resource, -1);
5955
}
6056
}

Tests/Loader/DirectoryLoaderTest.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ public function testImports()
5858
}
5959

6060
/**
61-
* @covers Symfony\Component\DependencyInjection\Loader\DirectoryLoader::__construct
62-
* @covers Symfony\Component\DependencyInjection\Loader\DirectoryLoader::load
63-
*
6461
* @expectedException \InvalidArgumentException
6562
* @expectedExceptionMessage The file "foo" does not exist (in:
6663
*/
@@ -69,12 +66,9 @@ public function testExceptionIsRaisedWhenDirectoryDoesNotExist()
6966
$this->loader->load('foo/');
7067
}
7168

72-
/**
73-
* @covers Symfony\Component\DependencyInjection\Loader\DirectoryLoader::supports
74-
*/
7569
public function testSupports()
7670
{
77-
$loader = new DirectoryLoader(new ContainerBuilder(), new FileLocator());
71+
$loader = new DirectoryLoader(new ContainerBuilder(), new FileLocator());
7872

7973
$this->assertTrue($loader->supports('directory/'), '->supports("directory/") returns true');
8074
$this->assertTrue($loader->supports('directory/', 'directory'), '->supports("directory/", "directory") returns true');

0 commit comments

Comments
 (0)