[DI] Allow using parameters in "prototype" resource paths
This commit is contained in:
parent
35afac00a0
commit
d3fc86c709
@ -85,6 +85,8 @@ abstract class FileLoader extends BaseFileLoader
|
||||
|
||||
private function findClasses($namespace, $resource)
|
||||
{
|
||||
$parameterBag = $this->container->getParameterBag();
|
||||
$resource = $parameterBag->unescapeValue($parameterBag->resolveValue($resource));
|
||||
$classes = array();
|
||||
$extRegexp = defined('HHVM_VERSION') ? '/\\.(?:php|hh)$/' : '/\\.php$/';
|
||||
$prefixLen = null;
|
||||
|
@ -15,12 +15,14 @@ use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\Config\Loader\LoaderResolver;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\DependencyInjection\Loader\FileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\IniFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\Bar;
|
||||
|
||||
class FileLoaderTest extends TestCase
|
||||
{
|
||||
@ -73,6 +75,17 @@ class FileLoaderTest extends TestCase
|
||||
|
||||
$this->assertEquals(array_keys($expected), array_keys($actual), '->load() imports and merges imported files');
|
||||
}
|
||||
|
||||
public function testRegisterClasses()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->setParameter('sub_dir', 'Sub');
|
||||
$loader = new TestFileLoader($container, new FileLocator(self::$fixturesPath.'/Fixtures'));
|
||||
|
||||
$loader->registerClasses(new Definition(), 'Symfony\Component\DependencyInjection\Tests\Fixtures\Prototype\Sub\\', 'Prototype/%sub_dir%/*');
|
||||
|
||||
$this->assertTrue($container->has(Bar::class));
|
||||
}
|
||||
}
|
||||
|
||||
class TestFileLoader extends FileLoader
|
||||
|
Reference in New Issue
Block a user