Merge pull request #24 from havvg/master
fix StreamWrapper configuration
This commit is contained in:
commit
60bf97cb66
|
@ -6,7 +6,7 @@ namespace Knp\Bundle\GaufretteBundle;
|
||||||
* Holds references to all declared filesystems
|
* Holds references to all declared filesystems
|
||||||
* and allows to access them through their name
|
* and allows to access them through their name
|
||||||
*/
|
*/
|
||||||
class FilesystemMap
|
class FilesystemMap implements \IteratorAggregate
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Map of filesystems indexed by their name
|
* Map of filesystems indexed by their name
|
||||||
|
@ -26,9 +26,13 @@ class FilesystemMap
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Retrieves a filesystem by its name.
|
||||||
|
*
|
||||||
* @param string $name name of a filesystem
|
* @param string $name name of a filesystem
|
||||||
|
*
|
||||||
|
* @return \Gaufrette\Filesystem
|
||||||
|
*
|
||||||
* @throw \InvalidArgumentException if the filesystem does not exist
|
* @throw \InvalidArgumentException if the filesystem does not exist
|
||||||
* @return Filesystem
|
|
||||||
*/
|
*/
|
||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
|
@ -38,4 +42,9 @@ class FilesystemMap
|
||||||
|
|
||||||
return $this->map[$name];
|
return $this->map[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getIterator()
|
||||||
|
{
|
||||||
|
return new \ArrayIterator($this->map);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,12 +27,19 @@ class KnpGaufretteBundle extends Bundle
|
||||||
|
|
||||||
$fileSystems = $this->container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
|
$fileSystems = $this->container->getParameter('knp_gaufrette.stream_wrapper.filesystems');
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are no filesystems configured to be wrapped,
|
||||||
|
* all filesystems within the map will be wrapped.
|
||||||
|
*/
|
||||||
if (empty($fileSystems)) {
|
if (empty($fileSystems)) {
|
||||||
$fileSystems = $this->container->get('knp_gaufrette.filesystem_map');
|
$fileSystems = $this->container->get('knp_gaufrette.filesystem_map');
|
||||||
}
|
foreach ($fileSystems as $domain => $fileSystem) {
|
||||||
|
$wrapperFsMap->set($domain, $fileSystem);
|
||||||
foreach ($fileSystems as $domain => $fileSystem) {
|
}
|
||||||
$wrapperFsMap->set($domain, $this->container->get('knp_gaufrette.filesystem_map')->get($fileSystem));
|
} else {
|
||||||
|
foreach ($fileSystems as $domain => $fileSystem) {
|
||||||
|
$wrapperFsMap->set($domain, $this->container->get('knp_gaufrette.filesystem_map')->get($fileSystem));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,10 +113,15 @@ class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||||
$this->assertEquals('gaufrette', $container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
|
$this->assertEquals('gaufrette', $container->getParameter('knp_gaufrette.stream_wrapper.protocol'));
|
||||||
|
|
||||||
$wrapperFsMap = StreamWrapper::getFilesystemMap();
|
$wrapperFsMap = StreamWrapper::getFilesystemMap();
|
||||||
$fileSystems = $this->kernel->getContainer()->get('knp_gaufrette.filesystem_map');
|
|
||||||
|
|
||||||
foreach($fileSystems as $fs) {
|
$expectedDomains = array(
|
||||||
$this->assertTrue($wrapperFsMap->has($fs));
|
'foo',
|
||||||
|
'cache',
|
||||||
|
'ftp',
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($expectedDomains as $eachExpectedDomain) {
|
||||||
|
$this->assertTrue($wrapperFsMap->has($eachExpectedDomain));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user