A
A
Alexey Skobkin2014-09-05 19:23:51
Java
Alexey Skobkin, 2014-09-05 19:23:51

How to substitute the value of the previous parameter in the Symfony2 bundle configuration?

There is a bundle where you need to upload files. I plan to store two paths in the config - an external path to a specific directory where the downloaded file will be saved and an internal path to the web directory. From these two paths, you can get both the full internal path for moving the file after downloading, and generate an address for display on the web.
At the moment the configuration looks something like this:

some_bundle:
    xxx:
        title_image:
            web_root_path: /uploads/xxx
            upload_root_path: %kernel.root_dir%/../web%web_root_path%
            thumbnails:
                enabled: true
                width: 600
                height: 400

And on this very %web_root_path% an exception is thrown:
ParameterNotFoundException: You have requested a non-existent parameter "web_root_path".

I tried to specify with "namespace" as "%kernel.root_dir%": "%some_bundle.xxx.title_image.web_root_path%", but this option did not work either.
Is it even possible to use the previous node of the same level to substitute the value? Or store both paths and add them already in the code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2016-08-12
@zolt85

Official documentation for all Spring projects . Each project has links to sample applications using that project.

S
Sergey, 2014-09-05
@skobkin

You only have access to those parameters that are registered in DI at the time you start parsing the config. That is, %kernel.root_dir% is available there (as well as a bunch of other parameters), but you yourself must register %web_root_path% as a parameter in YourBundle/DependencyInjection/Extension.
it is better to specify the full path where to save, and the path to web_root separately.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question