当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayNodeDefinition::requiresAtLeastOneElement方法代码示例

本文整理汇总了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;
 }
开发者ID:sergiuszm,项目名称:RabbitMqBundle,代码行数:9,代码来源:Configuration.php

示例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;
 }
开发者ID:vinhdrt,项目名称:FilterManagerBundle,代码行数:52,代码来源:Configuration.php


注:本文中的Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::requiresAtLeastOneElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。