本文整理汇总了PHP中Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::requiresAtLeastOneElement方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayNodeDefinition::requiresAtLeastOneElement方法的具体用法?PHP ArrayNodeDefinition::requiresAtLeastOneElement怎么用?PHP ArrayNodeDefinition::requiresAtLeastOneElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
的用法示例。
在下文中一共展示了ArrayNodeDefinition::requiresAtLeastOneElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMultipleQueuesConfiguration
protected function getMultipleQueuesConfiguration()
{
$node = new ArrayNodeDefinition('queues');
$prototypeNode = $node->requiresAtLeastOneElement()->prototype('array');
$this->addQueueNodeConfiguration($prototypeNode);
$prototypeNode->children()->scalarNode('callback')->isRequired()->end()->end();
$prototypeNode->end();
return $node;
}
示例2: buildFilterTree
/**
* Builds filter config tree for given filter name.
*
* @param string $filterName
*
* @return ArrayNodeDefinition
*/
private function buildFilterTree($filterName)
{
$filter = new ArrayNodeDefinition($filterName);
/** @var ParentNodeDefinitionInterface $node */
$node = $filter->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('name')->end()->arrayNode('relations')->children()->append($this->buildRelationsTree('search'))->append($this->buildRelationsTree('reset'))->end()->end()->scalarNode('request_field')->info('URL parameter name.')->isRequired()->end()->scalarNode('field')->info('Document field name.')->end()->arrayNode('tags')->info('Filter tags that will be passed to view data.')->prototype('scalar')->end()->end()->end();
switch ($filterName) {
case 'choice':
case 'multi_choice':
$node->children()->integerNode('size')->info('Result size to return.')->end()->arrayNode('sort')->children()->enumNode('type')->values(['_term', '_count'])->defaultValue('_term')->end()->enumNode('order')->values(['asc', 'desc'])->defaultValue('asc')->end()->arrayNode('priorities')->prototype('scalar')->end()->end()->end()->end();
break;
case 'fuzzy':
$node->children()->scalarNode('fuzziness')->info('The maximum edit distance.')->end()->integerNode('prefix_length')->info('The number of initial characters which will not be “fuzzified”.
This helps to reduce the number of terms which must be examined.')->end()->integerNode('max_expansions')->info('The maximum number of terms that the fuzzy query will expand to.')->end()->end();
break;
case 'sort':
$node->children()->arrayNode('choices')->prototype('array')->beforeNormalization()->always(function ($v) {
if (empty($v['fields']) && !empty($v['field'])) {
$field = ['field' => $v['field']];
if (array_key_exists('order', $v)) {
$field['order'] = $v['order'];
}
if (array_key_exists('mode', $v)) {
$field['mode'] = $v['mode'];
}
$v['fields'][] = $field;
}
if (empty($v['label'])) {
$v['label'] = $v['fields'][0]['field'];
}
return $v;
})->end()->addDefaultsIfNotSet()->children()->scalarNode('label')->end()->scalarNode('field')->end()->scalarNode('order')->defaultValue('asc')->end()->scalarNode('mode')->defaultNull()->end()->scalarNode('key')->info('Custom parameter value')->end()->booleanNode('default')->defaultFalse()->end()->arrayNode('fields')->isRequired()->requiresAtLeastOneElement()->prototype('array')->children()->scalarNode('field')->isRequired()->end()->scalarNode('order')->defaultValue('asc')->end()->scalarNode('mode')->defaultNull()->end()->end()->end()->end()->end()->end()->end();
break;
case 'pager':
$node->children()->integerNode('count_per_page')->info('Item count per page')->defaultValue(10)->end()->integerNode('max_pages')->info('Max pages displayed in pager at once.')->defaultValue(8)->end()->end();
break;
case 'range':
case 'date_range':
$node->children()->booleanNode('inclusive')->info('Whether filter should match range ends.')->defaultFalse()->end()->end();
break;
default:
// Should not happen.
break;
}
return $filter;
}