lexxpavlov / LexxpavlovSettingsBundle

This bundle helps you to manage your settings in Symfony2/3 project
MIT License
10 stars 10 forks source link

Settings does not exist #4

Closed AVATOR closed 7 years ago

AVATOR commented 7 years ago

Hi. I try to get data by "name" which doesn't exist and get error Error: Call to a member function getValue() on null

Please, return "" if settings don't exist.

lexxpavlov commented 7 years ago

I don't think that settings may be dynamic. If you need with concrete setting, than create it. I supposed that settings will use as static rarely changed values.

How do you plan to use settings so that it can be null?

AVATOR commented 7 years ago

I work with Magento and it return "" if setting can not find. Example: I create setting "heder_phone". Web-site will stop work if manager accidentally deleted a setting.

lexxpavlov commented 7 years ago

It's really bug. I will fix soon.

You can configure SonataAdminBundle that manager can't delete setting (superadmin can everything):

# app/config/config.yml
sonata_admin:
    security:
        handler: sonata.admin.security.handler.role

# app/config/security.yml
security:
    role_hierarchy:
        ROLE_SONATA_MANAGER:
            - ROLE_APP_ADMIN_ARTICLE_ALL
            - ROLE_LEXXPAVLOV_SONATA_ADMIN_SETTINGS_LIST
            - ROLE_LEXXPAVLOV_SONATA_ADMIN_SETTINGS_EDIT
            - ROLE_LEXXPAVLOV_SONATA_ADMIN_SETTINGS_SHOW
#            - ROLE_APP_ADMIN_USER_ALL

        ROLE_ADMIN:       [ ROLE_USER, ROLE_SONATA_ADMIN ]
        ROLE_MANAGER:     [ ROLE_ADMIN, ROLE_SONATA_MANAGER ]
        ROLE_SUPER_ADMIN: [ ROLE_MANAGER, ROLE_ALLOWED_TO_SWITCH ]

See security docs.

AVATOR commented 7 years ago

I have created pull request https://github.com/lexxpavlov/LexxpavlovSettingsBundle/pull/5