- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试定义我的包的用户可用的配置参数,但在识别根节点时遇到问题。
我创建了一个带有 getConfigTreeBuilder
的 Configuration
类,如下所示:
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('rally_stats');
// Here you should define the parameters that are allowed to
// configure your bundle. See the documentation linked above for
// more information on that topic.
$rootNode->children()->arrayNode('projects')
->prototype('scalar')->end();
return $treeBuilder;
}
使用它,我希望能够在 config.yml
中创建一个如下所示的部分:
rally_stats:
projects:
- project1
- project2
然后能够通过以下方式访问配置:
$this->getContainer()->getParameter('rally_stats.projects');
但是,当尝试加载该配置时,我收到此错误:
[Symfony\Component\Config\Exception\FileLoaderLoadException]
There is no extension able to load the configuration for "rally_stats"
(in /Users/stu/Projects/rally-stats/app/config/config.yml). Looked for namespace "rally_stats", found "framework", "security", "
twig", "monolog", "swiftmailer", "assetic", "doctrine", "sensio_framework_extra",
"wa_ndisco_rally_stats", "jms_di_extra", "jms_aop", "debug", "web_profiler", "sensio_distribution"
in /Users/stu/Projects/rally-stats/app/config/config.yml
(which is being imported from "/Users/stu/Projects/rally-stats/app/config/config_dev.yml").
最接近的是 wa_ndisco_rally_stats
,它是 Symfony 生成包时的原始根名称。我已经对此进行了 grep 查找,并且只是 wa_ndisco
并且没有其他引用。
如果我删除我的包的配置部分和转储引用,我会得到:
# Default configuration for "WANdiscoRallyStatsBundle"
rally_stats:
projects: []
为什么我无法使用我提供的节点名称添加配置?
如果我确实给了它它认为应该有wa_ndisco_rally_stats
的名称,我也无法访问它,我也会收到该名称相同的错误。
最佳答案
首先你的配置是错误的:
$rootNode->children()->arrayNode('projects')
->prototype('scalar')->end();
应该是:
$rootNode
->children()
->arrayNode('projects')
->prototype('scalar')->end()
->end()
->end();
如果你想从参数访问它,你必须转到你的包扩展类并设置它,例如:
$container->setParameter('rally_stats.projects', $config['projects']);
Here你可以阅读一些相关内容。
关于Symfony2 配置 rootNode 无法识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28906181/
我正在尝试定义我的包的用户可用的配置参数,但在识别根节点时遇到问题。 我创建了一个带有 getConfigTreeBuilder 的 Configuration 类,如下所示: /** * {@in
我想像这样创建一个 xml 文档和根元素: 我尝试这样创建: XmlDocument doc = new XmlDocument(); XmlNode rootNode = doc
如何以编程方式从 c# 中的 wpf TreeView 中选择根节点,这是带有 xmlDataProvider 的 databindet? 在我的例子中,根节点来自 DataType="cards":
我从 firebase 收到以下回复。我需要将自动生成的根节点复制为子节点。 { "-LcjpjUB1ucnzDabnHa9": { "CustomerId": "9ff2a33e-815e-
我正在尝试从我的场景中删除一组代表路径的节点。它们是使用 SCNGeometrySource 和 SCNGeometryElement 创建的 SCNSphere 几何节点和表示线的自定义几何图形的组
当我将 CustomComponent (GKComponent) 添加到 Xcode SpriteKit 场景编辑器中的实体并尝试使用 GKScene.init< 加载该 .sks 文件时,GKSc
我是一名优秀的程序员,十分优秀!