我有一个名为Web\CoworkerBundle的Bundle.在DIC/Configuration.php中我有:
$rootNode = $treeBuilder->root('web_coworker');
$rootNode
->children()
->scalarNode('redirect_url')->defaultNull()->end()
->end();
Run Code Online (Sandbox Code Playgroud)
在config.yml我有:
web_coworker:
redirect_url: "http://www.example.com/"
Run Code Online (Sandbox Code Playgroud)
现在在我的DefaultController.php中,我这样做
return array(
'url' => $this->container->getParameter('redirect_url')
);
Run Code Online (Sandbox Code Playgroud)
我收到了错误
必须定义参数"redirect_url".
我错过了什么吗?
Geo*_*ier 14
您需要在捆绑中创建扩展名(Acme/DemoBundle/DependencyInjection)
class AcmeDemoBundleExtension extends Extension
{
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');
// MOST IMPORTANT LINE
$container->setParameter('web_coworker.params', $config);
}
}
Run Code Online (Sandbox Code Playgroud)
现在关于控制器你可以删除你返回的东西,应该做的伎俩:)
归档时间: |
|
查看次数: |
8844 次 |
最近记录: |