我的参数定义为:
parameters:
config1:
title: Title 1
data_proc: getDataOne
options: [things, stuff]
config2:
title: Title 2
data_proc: getDataTwo
options: [things, stuff]
#...
服务定义为
my_service:
class: Me\MyBundle\Services\MyService
arguments:
- @security.context
- @doctrine.dbal.my_connection
- %config% # the parameter that I'd like to be dynamic
控制器喜欢
class ProduitController extends Controller
{
public function list1Action()
{
$ssrs = $this->get('my_service'); // with config1 params
# ...
}
public function list2Action()
{
$ssrs = $this->get('my_service'); // with config2 params
# ...
}
#...
}
几个控制器使用my_service
.
我list1Action()
应该my_service
通过只注入config1
参数来调用
我怎样才能做到这一点而不必定义与控制器一样多的服务?