How to bind parameter value to constant string in Yamla

I have a url defined as a parameter in parameters.yml

. I want to create a service that is a SOAP client. The SOAP client argument is the URL for the file wsdl

. In my case, the url of the file is wsdl

: "%parameter_url%"

+ "? Wsdl" `.

Is there a way to bind "? Wsdl" to a parameter already defined in YAML?

+4


source to share


3 answers


You don't need the concatenation symbol, you can add the constant directly after the parameter. For example, to define a service in services.yml:



my.service:
    class:         %my.service.class%
    arguments:     
      - @logger, 
      - %some_parameter%, 
      - %parameter_url%?wsdl, 

      

+16


source


If you want to combine two parameters. You can do it like this:

parameters.yml

parameter_url: XXXXX parameter_type: ?wsdl



services.yml

my.service:
    class: %my.service.class%
    arguments:     
        - @logger, 
        - %some_parameter%, 
        - '%parameter_url%%parameter_type%',

      

+2


source


In response to redbirdo's his answer, since refusing to quote a scalar starting with the '%' indicator character is deprecated as of Symfony 3.1:

my.service:
  class: "%my.service.class%"
  arguments:
    - "@logger"
    - "%some_parameter%"
    - "%parameter_url%?wsdl"

# OR

my.service:
  class: "%my.service.class%"
  arguments: ["@logger", "%some_parameter%", "%parameter_url%?wsdl"]

      

0


source







All Articles