本文整理汇总了PHP中Symfony\Component\Config\Definition\Builder\NodeDefinition类的典型用法代码示例。如果您正苦于以下问题:PHP NodeDefinition类的具体用法?PHP NodeDefinition怎么用?PHP NodeDefinition使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeDefinition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addConfiguration
public function addConfiguration(NodeDefinition $node)
{
$node->fixXmlConfig('user_provider');
$builder = $node->beforeNormalization()->ifTrue(function ($v) {
return isset($v['key']);
})->then(function ($v) {
if (isset($v['secret'])) {
throw new \LogicException('Cannot set both key and secret options for remember_me, use only secret instead.');
}
@trigger_error('remember_me.key is deprecated since version 2.8 and will be removed in 3.0. Use remember_me.secret instead.', E_USER_DEPRECATED);
$v['secret'] = $v['key'];
unset($v['key']);
return $v;
})->end()->children();
$builder->scalarNode('secret')->isRequired()->cannotBeEmpty()->end()->scalarNode('token_provider')->end()->arrayNode('user_providers')->beforeNormalization()->ifString()->then(function ($v) {
return array($v);
})->end()->prototype('scalar')->end()->end()->scalarNode('catch_exceptions')->defaultTrue()->end();
foreach ($this->options as $name => $value) {
if (is_bool($value)) {
$builder->booleanNode($name)->defaultValue($value);
} else {
$builder->scalarNode($name)->defaultValue($value);
}
}
}
示例2: getConfigTreeExtension
/**
* Generates the configuration tree builder.
*
*/
public function getConfigTreeExtension(NodeDefinition $rootNode)
{
$rootNode->children()->scalarNode('min')->isRequired()->info('Starting Number')->example('A numeric number like 1 or 1.67 or 0.87')->validate()->ifTrue(function ($v) {
return !is_numeric($v);
})->then(function ($v) {
throw new EngineException('Range::min Numeric is required');
})->end()->end()->scalarNode('max')->isRequired()->example('A numeric number like 1 or 1.67 or 0.87')->info('The maxium to use in range')->validate()->ifTrue(function ($v) {
return !is_numeric($v);
})->then(function ($v) {
throw new EngineException('Range::max Numeric is required');
})->end()->end()->scalarNode('step')->defaultValue(false)->example('1 , 1.5 , 0.6')->info('Stepping value applied on every increment, not supplied will use random')->validate()->ifTrue(function ($v) {
return !(is_numeric($v) || $v === false);
})->then(function ($v) {
throw new EngineException('Range::Step option should be numeric or bool(false) to use random step');
})->end()->end()->scalarNode('windowStep')->info('Value to add to the base after the iteration has finished (reached max)')->example(1)->defaultValue(0)->validate()->ifTrue(function ($x) {
return !is_numeric($x);
})->then(function ($x) {
throw new EngineException('Range:: windowStep must be an number');
})->end()->end()->booleanNode('random')->defaultFalse()->example('false|true')->info('Enable random step value on every loop, step param must be set to false')->end()->scalarNode('round')->defaultValue(0)->example('an integer')->info('number of places to round too')->validate()->ifTrue(function ($v) {
return !(is_integer($v) && $v > 0);
})->then(function ($v) {
throw new EngineException('Range::Round option should be a positive integer >= 0');
})->end()->end()->end();
return $rootNode;
}
示例3: addConfiguration
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->end()
;
}
示例4: 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;
}
示例5: addConfiguration
/**
* {@inheritdoc}
*/
public function addConfiguration(NodeDefinition $node)
{
$node->fixXmlConfig('header')->children()->scalarNode('auth_header')->cannotBeEmpty()->defaultValue('Authorization')->end()->scalarNode('service_label')->cannotBeEmpty()->defaultValue('HMAC')->end()->scalarNode('algorithm')->beforeNormalization()->ifString()->then(function ($v) {
return strtolower($v);
})->end()->validate()->ifNotInArray(hash_algos())->thenInvalid('value %s is not supported, see hash_algos() for available hashing algorithms.')->end()->defaultValue('sha256')->end()->arrayNode('verify_headers')->beforeNormalization()->ifString()->then(function ($v) {
return array_map('trim', explode(',', $v));
})->end()->prototype('scalar')->end()->end()->end();
}
示例6: addConfiguration
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('client')->isRequired()->end()
->end()
;
}
示例7: addHandlersSection
/**
* @param NodeDefinition $node
* @param $name
* @param string $info block info line
* @param ConfigurationFactory[]|ArrayObject $factories
*/
private function addHandlersSection(NodeDefinition $node, $name, $info, ArrayObject &$factories)
{
$handlersNodeBuilder = $node->children()->arrayNode($name)->info($info)->useAttributeAsKey('name')->prototype('array')->performNoDeepMerging()->children();
foreach ($factories as $name => $factory) {
$factoryNode = $handlersNodeBuilder->arrayNode($name)->canBeUnset();
$factory->addConfiguration($factoryNode);
}
}
示例8: getConfigTreeExtension
/**
* Generates the configuration tree builder.
*
*/
public function getConfigTreeExtension(NodeDefinition $rootNode)
{
$rootNode->children()->booleanNode('value')->isRequired()->validate()->ifTrue(function ($v) {
return !empty($v);
})->then(function ($v) {
return (bool) $v;
})->end()->info('true or false')->example('true | false')->end()->end();
return $rootNode;
}
示例9: getConfigTreeExtension
public function getConfigTreeExtension(NodeDefinition $rootNode)
{
$rootNode->children()->scalarNode('probability')->isRequired()->info('')->example('0.3 | 0.4 | 0.5')->validate()->ifTrue(function ($v) {
return !is_numeric($v) || !($v > 0 && $v < 1);
})->then(function ($v) {
throw new EngineException('PickSelector::Probability must be between 0 and 1');
})->end()->end()->end();
return $rootNode;
}
示例10: getConfigTreeExtension
public function getConfigTreeExtension(NodeDefinition $rootNode)
{
$rootNode->children()->scalarNode('badOption')->treatNullLike('en')->defaultValue('en')->info('Abad option')->validate()->ifTrue(function ($v) {
return $v === 'bad';
})->then(function ($v) {
throw new InvalidConfigurationException('BadOption is equal to bad');
})->end()->end();
return $rootNode;
}
示例11: configureNode
public static function configureNode(NodeDefinition $node)
{
$node->children()->arrayNode("tags")->prototype("scalar")->end()->end()->scalarNode("query")->end()->booleanNode("filter_by_run_id")->end()->integerNode("limit")->defaultValue(10)->end()->arrayNode("processed_tags")->prototype("scalar")->end()->end()->end()->validate()->ifTrue(function ($v) {
if ((!isset($v["tags"]) || count($v["tags"]) == 0) && !isset($v["query"])) {
return true;
}
return false;
})->thenInvalid("At least one of 'tags' or 'query' parameters must be defined.");
}
示例12: addConfiguration
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('container')->isRequired()->end()
->scalarNode('prefix')->defaultNull()->end()
->end()
;
}
示例13: processNode
protected function processNode(NodeDefinition $definition, array $config, $sectionName = true)
{
$processor = new Processor();
$node = $definition->getNode(true);
if ($sectionName) {
$config = [$node->getName() => $config];
}
return $processor->process($node, $config);
}
示例14: getConfigTreeExtension
public function getConfigTreeExtension(NodeDefinition $rootNode)
{
$rootNode->children()->scalarNode('set')->isRequired()->info('The size of the set to pick from')->example('1 | 2 | 3')->validate()->ifTrue(function ($v) {
return !is_integer($v) || (int) $v < 1;
})->then(function ($v) {
throw new EngineException('RandomSelector::Set size is required and must be and integer > 0');
})->end()->end()->end();
return $rootNode;
}
示例15: addConfiguration
public function addConfiguration(NodeDefinition $node)
{
$node
->children()
->scalarNode('client')->isRequired()->end()
->scalarNode('key')->defaultValue('flysystem')->end()
->scalarNode('expires')->defaultNull()->end()
->end()
;
}