本文整理汇总了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;
}
示例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();
}
示例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();
}