簡體   English   中英

如何定義系統配置?

[英]how to define system configuration?

我使用 oro platform v4.1 我嘗試根據https://doc.oroinc.com/4.1/backend/system-configuration/為系統定義配置值

所以

class Configuration implements ConfigurationInterface
{

    /**
     * {@inheritDoc}
     */
    public function getConfigTreeBuilder()
    {
        $treeBuilder = new TreeBuilder();
        $rootNode = $treeBuilder->root('web_sys_visit');

        // Here you should define the parameters that are allowed to
        // configure your bundle. See the documentation linked above for
        // more information on that topic.

        SettingsBuilder::append($rootNode, [
            'nogps' => [
                'value' => true,
                'type' => 'boolean',
            ]
        ]);


        return $treeBuilder;
    }
}

和 system_configuration.yml

system_configuration:
    groups:
        websys_visit_settings:
            title: visit setting
    fields:
        web_sys_visit.nogps:
            data_type: boolean
            type: Oro\Bundle\ConfigBundle\Form\Type\ConfigCheckbox
            priority: 10
            options:
                label: No GPS
    tree:
        system_configuration:
            platform:
                children:
                    general_setup:
                        children:
                            application_settings:
                                children:
                                    websys_visit_settings:
                                        children:
                                            - web_sys_visit.nogps
class WebSysVisitExtension extends Extension
{
    const ALIAS = 'web_sys_visit';

    /**
     * {@inheritDoc}
     */
    public function load(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $config = $this->processConfiguration($configuration, $configs);
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.yml');
        $loader->load('form.yml');
    }

    /**
     * {@inheritDoc}
     */
    public function getAlias()
    {
        return self::ALIAS;
    }
}

當我嘗試清除緩存時出現以下錯誤

未定義系統配置變量“web_sys_visit.nogps”。 請確保將其添加到捆綁配置中
設置或在配置中標記為“ui_only”。

所以我加

ui_only:真

配置並清除緩存,然后運行 oro:entity-config:update

我在系統配置中看到 gps 配置,但是當我將值設置為 true 時,它沒有保存

我檢查了數據庫中的 oro_confige_value 表,沒有作為 nogps 的配置(section =web_sys_visit)我應該運行任何命令嗎? 你可以幫幫我嗎? 謝謝

ui_only 表示該值不會由框架自動保存,您必須手動處理。

似乎未加載配置 class。 確保命名空間和文件路徑正確,並且您的包 class 名稱是 WebSysVisitBundle,否則擴展名稱不正確。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM