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


PHP NodeDefinition::validate方法代码示例

本文整理汇总了PHP中Symfony\Component\Config\Definition\Builder\NodeDefinition::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeDefinition::validate方法的具体用法?PHP NodeDefinition::validate怎么用?PHP NodeDefinition::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Config\Definition\Builder\NodeDefinition的用法示例。


在下文中一共展示了NodeDefinition::validate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validateDriver

 /**
  * @param NodeDefinition $node
  * @param string         $driver
  * @param string         $option
  *
  * @return self
  */
 private function validateDriver(NodeDefinition $node, $driver, $option)
 {
     $node->validate()->ifTrue(function ($v) use($driver, $option) {
         return $driver === $v['driver'] && empty($v['options'][$option]);
     })->thenInvalid(sprintf('The "%s" option must be defined when using the "%s" driver.', $option, $driver))->end();
     return $this;
 }
开发者ID:johanderuijter,项目名称:BernardBundle,代码行数:14,代码来源:Configuration.php

示例2: addConfiguration

 /**
  * {@inheritDoc}
  */
 public function addConfiguration(NodeDefinition $builder)
 {
     $builder->validate()->always(function ($v) {
         if (!empty($v['acl']) && !empty($v['users'])) {
             throw new \Exception('"acl", and "users" cannot be set both at the same time.');
         }
         return $v;
     })->end()->fixXmlConfig('user')->children()->scalarNode('amazon_s3_id')->isRequired()->cannotBeEmpty()->end()->scalarNode('bucket_name')->isRequired()->cannotBeEmpty()->end()->scalarNode('acl')->cannotBeEmpty()->end()->arrayNode('users')->prototype('array')->validate()->always(function ($v) {
         if (!empty($v['group']) === !empty($v['id'])) {
             throw new \Exception('Either "group", or "id" must be set.');
         }
         return $v;
     })->end()->children()->scalarNode('group')->cannotBeEmpty()->end()->scalarNode('id')->cannotBeEmpty()->end()->scalarNode('permission')->isRequired()->cannotBeEmpty()->end()->end()->end()->end()->booleanNode('create')->defaultFalse()->end()->arrayNode('options')->children()->booleanNode('create')->defaultFalse()->end()->scalarNode('region')->end()->scalarNode('directory')->end()->end()->end()->end();
 }
开发者ID:RicardoSantosDiaz,项目名称:KnpGaufretteBundle,代码行数:17,代码来源:AclAwareAmazonS3AdapterFactory.php

示例3: addItemsSorting

 /**
  * Add rules to sort items by 'order' attribute
  *
  * @param NodeDefinition $node
  */
 protected function addItemsSorting(NodeDefinition $node)
 {
     $node->validate()->always(function ($v) {
         return $this->sortItems($v);
     })->end();
 }
开发者ID:ramunasd,项目名称:platform,代码行数:11,代码来源:Configuration.php


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