Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 passing associative array as argument in service definition issue

I am trying to pass an associative array as argument to a service definition (Solarium, to be precise). However, I get the following error:

"Catchable Fatal Error: Argument 1 passed to Symfony\Component\DependencyInjection\Definition::setArguments() must be of the type array, string given, "

My services.yml reads as follows:

parameters:
    mynamespace.api.solrclient.config: 
        endpoint:
            solrserver:
                host: "search.mysite.com"
                port: "80"
                path: "/solr/"

services:        
    mynamespace.api.solrclient:
        class: Solarium\Client
        arguments: "%mynamespace.api.solrclient.config%"

Is there anything obviously wrong with the way I have defined the parameter array?

like image 868
Prathap Avatar asked Apr 24 '13 17:04

Prathap


1 Answers

arguments must be an array, try:

services:
    mynamespace.api.solrclient:
        class: Solarium\Client
        arguments: [%mynamespace.api.solrclient.config%]
like image 90
Nuno Costa Avatar answered Nov 08 '22 16:11

Nuno Costa