merged branch hason/config_import (PR #6226)
This PR was merged into the 2.0 branch.
Commits
-------
8bb3208
[Config] Loader::import must return imported data
Discussion
----------
[2.0][2.1][2.2] [Config] Loader::import must return imported data
Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
License of the code: MIT
---------------------------------------------------------------------------
by fabpot at 2012-12-07T13:40:58Z
why?
---------------------------------------------------------------------------
by hason at 2012-12-07T20:57:06Z
We should support both approaches to importing. The first case assumes shared object accross all the loaders (loading DI configuration) and the second case requires returning of imported object (merging route collections).
---------------------------------------------------------------------------
by stof at 2012-12-07T21:38:42Z
@fabpot As ``load`` can have a return value, this PR makes sense IMO
---------------------------------------------------------------------------
by fabpot at 2012-12-10T12:44:09Z
This change should be done in master then.
---------------------------------------------------------------------------
by stof at 2012-12-10T14:43:18Z
@fabpot I would consider it as a bugfix. The routing loaders are simply broken (as of 2.0) if the loader does not extend from FileLoader (which overwrites the ``import`` method and takes care to return the value). the routing loaders expect to receive the loaded data when importing instead of loosing the imported data entirely: https://github.com/symfony/Routing/blob/2.0/Loader/XmlFileLoader.php#L80
This commit is contained in:
commit
5c15496b5c
@ -47,10 +47,12 @@ abstract class Loader implements LoaderInterface
|
||||
*
|
||||
* @param mixed $resource A Resource
|
||||
* @param string $type The resource type
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function import($resource, $type = null)
|
||||
{
|
||||
$this->resolve($resource)->load($resource, $type);
|
||||
return $this->resolve($resource)->load($resource, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,6 +55,15 @@ class LoaderTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertInstanceOf('Symfony\Component\Config\Exception\FileLoaderLoadException', $e, '->resolve() throws a FileLoaderLoadException if the resource cannot be loaded');
|
||||
}
|
||||
}
|
||||
|
||||
public function testImport()
|
||||
{
|
||||
$loader = $this->getMock('Symfony\Component\Config\Loader\Loader', array('supports', 'load'));
|
||||
$loader->expects($this->once())->method('supports')->will($this->returnValue(true));
|
||||
$loader->expects($this->once())->method('load')->will($this->returnValue('yes'));
|
||||
|
||||
$this->assertEquals('yes', $loader->import('foo'));
|
||||
}
|
||||
}
|
||||
|
||||
class ProjectLoader1 extends Loader
|
||||
|
Reference in New Issue
Block a user