sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Env variable to define sonata_admin.options.skin #8014

Closed ec-ecss closed 1 year ago

ec-ecss commented 1 year ago

Feature Request

I am on admin-bundle 4.9 The config variable sonata_admin.options.skin needs a constant string Is it possible to make it customizable with a environnement variable ? Currently a "%env(SOMETHING)% is not functionnal and an exception about a empty string is triggered

haivala commented 1 year ago

Pass it to service parameter first and then use that

ec-ecss commented 1 year ago

Hello thank you very much for your answer. I'm so sorry... but could you just specify what is the service you talk about, and "it" and "that" ? It's not clear for me... I know well sf, but not sonata.

haivala commented 1 year ago

in parameters.yml

parameters:
     skin: "env..

and then in sonata_admin.yml you should be able to access that with %skin%

https://symfonycasts.com/screencast/symfony5-fundamentals/parameters#reading-parameters-in-config-files

ec-ecss commented 1 year ago

Tx. I've tried :

parameters:
  app_skin: '%env(APP_SKIN)%'
sonata_admin:
  title: '%env(APP_TITLE)%'
  dashboard:
    blocks:
      - { type: sonata.admin.block.admin_list, position: left }
  title_logo: '%env(APP_LOGO)%'
  options:
    skin: '%app_skin%'

But still got error The value "" is not allowed for path "sonata_admin.options.skin". Permissible values: "skin-black", etc...

Obviously the APP_SKIN is well defined in .env.local

APP_SKIN='skin-red-light'
jordisala1991 commented 1 year ago

Maybe you can do something like:

parameters:
    env(APP_SKIN): 'skin-red-light' # default value

And then it will be overriden with the env value on your .env

Besides this, not sure what else we could do. This is a symfony feature that we are using. We need to make sure the value on that config option is a valid option.

Closing for now. If my suggestion does not work and you have an idea on how we could improve this (knowing that this might be a symfony issue), please let us know.

Thank you.