如何定义系统配置?
我使用oro平台v4.1 我尝试根据系统定义配置值 https://doc.oroinc.com/4.1/backend/system-configuration/< /a>
so
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”未定义。请确保将其添加到捆绑配置中
设置或在 config.php 中标记为“ui_only”
所以我将
ui_only: true
添加到配置中并清除缓存,然后运行 oro:entity-config:update
我在系统配置中看到 gps 配置 但 当我设置值 true 时,它没有保存
,我检查数据库中的 oro_confige_value 表,没有配置为 nogps (部分= web_sys_visit) 我应该运行任何命令吗? 你能帮我吗? 谢谢
I use oro platform v4.1
I try to defind configuration value to system according to
https://doc.oroinc.com/4.1/backend/system-configuration/
so
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;
}
}
and 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;
}
}
when I try to clear the cache I have the below error
The system configuration variable "web_sys_visit.nogps" is not defined. Please make sure that it is either added to bundle configuration
settings or marked as "ui_only" in config.
so I add
ui_only: true
to the configuration and clear cache and then run oro:entity-config:update
I see gps configuration in system configuration
but
when I set value true, It was not saved
I check oro_confige_value table in db ,there is no config as nogps ( section =web_sys_visit)
should I run any command?
could you help me?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ui_only 表示框架不会自动保存该值,您必须手动处理它。
看来配置类没有加载。确保命名空间和文件路径正确,并且您的包类名称为 WebSysVisitBundle,否则扩展名称不正确。
ui_only means that the value is not saved automatically by the framework and you have to handle it manually.
It seems the Configuration class is not loaded. Make sure namespaces and file paths are correct and your bundle class name is WebSysVisitBundle, otherwise the extension name is incorrect.