Я пытаюсь выставить настраиваемую конфигурацию, определенную для моего пакета, который называется DecisionBundle.Проблема с конфигурацией пакета Symfony2
У меня есть решение \ DecisionBundle \ Resources \ Config \ custom.yaml который выглядит следующим образом:
decision:
testValue: 11
anotherTest: 12
У меня также есть расширение, которое выглядит следующим образом:
namespace Decision\DecisionBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader;
class DecisionExtension extends Extension
{
/**
* {@inheritDoc}
*/
public function load(array $configs, ContainerBuilder $container)
{
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('custom.yml');
}
}
Файл пользовательского .yml кажется загруженным нормально. Далее идет Конфигурационный интерфейс
namespace Decision\DecisionBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
/**
* {@inheritDoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('decision');
$rootNode
->children()
->scalarNode('testValue')->defaultValue('0')->end()
->scalarNode('anotherTest')->defaultValue('0')->end()
->end();
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
return $treeBuilder;
}
}
Однако это приводит к следующему:
InvalidArgumentException: There is no extension able to load the configuration for "decision" (in *****\src\Decision\DecisionBundle\DependencyInjection/../Resources/config\custom.yml). Looked for namespace "decision", found none
Может кто-нибудь мне точку, как к тому, что я делаю неправильно? Нужно ли мне вручную регистрировать расширение? Однако расширение, по-видимому, учитывается, поскольку оно выглядит загруженным из информации об отладке. Спасибо!