我正在学习如何创建自己的配置文件并将其实现在我的服务中。我有以下配置文件。
sample_helper:
admin:
key: '45912565'
secret: '2e6b9cd8a8cfe01418cassda3reseebafef9caaad0a7'
我成功地在我的依赖注入中使用配置创建了这个
private function addSampleConfiguration(ArrayNodeDefinition $node){
$node->children()
->arrayNode("admin")
->children()
->scalarNode('key')->end()
->scalarNode('secret')->end()
->end()
->end()
->end();
}
但是在我的服务中,我希望获取密钥值和秘密值。
class SampleService
{
public function generateSample(){
$key = ''; // key here from config
$secret = ''; //secret from config;
}
}
我尝试阅读文档,但实际上我不知道该如何做。我一无所知,不知道从哪里开始。
null
或两个false
值... - jkucharovic