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


PHP ArrayNodeDefinition::validate方法代码示例

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


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

示例1: addFormSection

 private function addFormSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->validate()->ifTrue(function ($v) {
         return count($v['form']['resources']) > 0;
     })->then(function ($v) {
         $v['form_themes'] = array_values(array_unique(array_merge($v['form']['resources'], $v['form_themes'])));
         return $v;
     })->end()->children()->arrayNode('form')->info('Deprecated since 2.6, to be removed in 3.0. Use twig.form_themes instead')->addDefaultsIfNotSet()->fixXmlConfig('resource')->children()->arrayNode('resources')->addDefaultChildrenIfNoneSet()->prototype('scalar')->defaultValue('form_div_layout.html.twig')->end()->example(array('MyBundle::form.html.twig'))->validate()->ifNotInArray(array('form_div_layout.html.twig'))->then(function ($v) {
         return array_merge(array('form_div_layout.html.twig'), $v);
     })->end()->end()->end()->end()->end();
 }
开发者ID:amber9111,项目名称:II-project,代码行数:11,代码来源:Configuration.php

示例2: addPaymentSection

 /**
  * @param  \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
  * @return void
  */
 private function addPaymentSection(ArrayNodeDefinition $node)
 {
     $node->validate()->ifTrue(function ($v) {
         foreach ($v['methods'] as $methodCode => $service) {
             if (null === $service || "" === $service) {
                 foreach ($v['services'] as $serviceConf) {
                     if ($methodCode === $serviceConf['code']) {
                         break 2;
                     }
                 }
                 return true;
             }
         }
         return false;
     })->thenInvalid("Custom payment methods require a service id. Provided payment methods need to be configured with their method code as key.")->end()->children()->arrayNode('services')->children()->arrayNode('paypal')->children()->scalarNode('name')->defaultValue('Paypal')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('paypal')->cannotBeEmpty()->end()->arrayNode('transformers')->children()->scalarNode('basket')->defaultValue('sonata.payment.transformer.basket')->cannotBeEmpty()->end()->scalarNode('order')->defaultValue('sonata.payment.transformer.order')->cannotBeEmpty()->end()->end()->end()->arrayNode('options')->children()->scalarNode('shop_secret_key')->cannotBeEmpty()->end()->scalarNode('web_connector_name')->defaultValue('curl')->cannotBeEmpty()->end()->scalarNode('account')->defaultValue('your_paypal_account@fake.com')->cannotBeEmpty()->end()->scalarNode('cert_id')->defaultValue('fake')->cannotBeEmpty()->end()->scalarNode('debug')->defaultValue(false)->cannotBeEmpty()->end()->scalarNode('paypal_cert_file')->defaultValue('%kernel.root_dir%/paypal_cert_pem_sandbox.txt')->cannotBeEmpty()->end()->scalarNode('url_action')->defaultValue('https://www.sandbox.paypal.com/cgi-bin/webscr')->cannotBeEmpty()->end()->scalarNode('class_order')->defaultValue('Application\\Sonata\\OrderBundle\\Entity\\Order')->cannotBeEmpty()->end()->scalarNode('url_callback')->defaultValue('sonata_payment_callback')->cannotBeEmpty()->end()->scalarNode('url_return_ko')->defaultValue('sonata_payment_error')->cannotBeEmpty()->end()->scalarNode('url_return_ok')->defaultValue('sonata_payment_confirmation')->cannotBeEmpty()->end()->scalarNode('method')->defaultValue('encryptViaBuffer')->cannotBeEmpty()->end()->scalarNode('key_file')->defaultValue('%kernel.root_dir%/my-prvkey.pem')->cannotBeEmpty()->end()->scalarNode('cert_file')->defaultValue('%kernel.root_dir%/my-pubcert.pem')->cannotBeEmpty()->end()->scalarNode('openssl')->defaultValue('/opt/local/bin/openssl')->cannotBeEmpty()->end()->end()->end()->end()->end()->arrayNode('debug')->children()->scalarNode('name')->defaultValue('Debug Payment')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('debug')->cannotBeEmpty()->end()->scalarNode('browser')->defaultValue('sonata.payment.browser.curl')->cannotBeEmpty()->end()->arrayNode('transformers')->children()->scalarNode('basket')->defaultValue('sonata.payment.transformer.basket')->cannotBeEmpty()->end()->scalarNode('order')->defaultValue('sonata.payment.transformer.order')->cannotBeEmpty()->end()->end()->end()->arrayNode('options')->children()->scalarNode('url_callback')->defaultValue('sonata_payment_callback')->cannotBeEmpty()->end()->scalarNode('url_return_ko')->defaultValue('sonata_payment_error')->cannotBeEmpty()->end()->scalarNode('url_return_ok')->defaultValue('sonata_payment_confirmation')->cannotBeEmpty()->end()->end()->end()->end()->end()->arrayNode('pass')->children()->scalarNode('name')->defaultValue('Pass')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('pass')->cannotBeEmpty()->end()->arrayNode('transformers')->children()->scalarNode('basket')->defaultValue('sonata.payment.transformer.basket')->cannotBeEmpty()->end()->scalarNode('order')->defaultValue('sonata.payment.transformer.order')->cannotBeEmpty()->end()->end()->end()->scalarNode('browser')->defaultValue('sonata.payment.browser.curl')->cannotBeEmpty()->end()->arrayNode('options')->children()->scalarNode('shop_secret_key')->cannotBeEmpty()->end()->scalarNode('url_callback')->defaultValue('sonata_payment_callback')->cannotBeEmpty()->end()->scalarNode('url_return_ko')->defaultValue('sonata_payment_error')->cannotBeEmpty()->end()->scalarNode('url_return_ok')->defaultValue('sonata_payment_confirmation')->cannotBeEmpty()->end()->end()->end()->end()->end()->arrayNode('check')->children()->scalarNode('name')->defaultValue('Check')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('check')->cannotBeEmpty()->end()->arrayNode('transformers')->children()->scalarNode('basket')->defaultValue('sonata.payment.transformer.basket')->cannotBeEmpty()->end()->scalarNode('order')->defaultValue('sonata.payment.transformer.order')->cannotBeEmpty()->end()->end()->end()->scalarNode('browser')->defaultValue('sonata.payment.browser.curl')->cannotBeEmpty()->end()->arrayNode('options')->children()->scalarNode('shop_secret_key')->cannotBeEmpty()->end()->scalarNode('url_callback')->defaultValue('sonata_payment_callback')->cannotBeEmpty()->end()->scalarNode('url_return_ko')->defaultValue('sonata_payment_error')->cannotBeEmpty()->end()->scalarNode('url_return_ok')->defaultValue('sonata_payment_confirmation')->cannotBeEmpty()->end()->end()->end()->end()->end()->arrayNode('scellius')->children()->scalarNode('name')->defaultValue('Scellius')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('scellius')->cannotBeEmpty()->end()->scalarNode('generator')->defaultValue('sonata.payment.provider.scellius.none_generator')->end()->arrayNode('transformers')->children()->scalarNode('basket')->defaultValue('sonata.payment.transformer.basket')->cannotBeEmpty()->end()->scalarNode('order')->defaultValue('sonata.payment.transformer.order')->cannotBeEmpty()->end()->end()->end()->arrayNode('options')->children()->scalarNode('url_callback')->defaultValue('sonata_payment_callback')->cannotBeEmpty()->end()->scalarNode('url_return_ko')->defaultValue('sonata_payment_error')->cannotBeEmpty()->end()->scalarNode('url_return_ok')->defaultValue('sonata_payment_confirmation')->cannotBeEmpty()->end()->scalarNode('template')->defaultValue('SonataPaymentBundle:Payment:scellius.html.twig')->cannotBeEmpty()->end()->scalarNode('shop_secret_key')->cannotBeEmpty()->end()->scalarNode('request_command')->cannotBeEmpty()->end()->scalarNode('response_command')->cannotBeEmpty()->end()->scalarNode('merchant_id')->cannotBeEmpty()->end()->scalarNode('merchant_country')->cannotBeEmpty()->end()->scalarNode('pathfile')->cannotBeEmpty()->end()->scalarNode('language')->cannotBeEmpty()->end()->scalarNode('payment_means')->cannotBeEmpty()->end()->scalarNode('base_folder')->cannotBeEmpty()->end()->scalarNode('data')->defaultValue('')->end()->scalarNode('header_flag')->defaultValue('no')->cannotBeEmpty()->end()->scalarNode('capture_day')->defaultValue('')->end()->scalarNode('capture_mode')->defaultValue('')->end()->scalarNode('bgcolor')->defaultValue('')->end()->scalarNode('block_align')->defaultValue('')->end()->scalarNode('block_order')->defaultValue('')->end()->scalarNode('textcolor')->defaultValue('')->end()->scalarNode('normal_return_logo')->defaultValue('')->end()->scalarNode('cancel_return_logo')->defaultValue('')->end()->scalarNode('submit_logo')->defaultValue('')->end()->scalarNode('logo_id')->defaultValue('')->end()->scalarNode('logo_id2')->defaultValue('')->end()->scalarNode('advert')->defaultValue('')->end()->scalarNode('background_id')->defaultValue('')->end()->scalarNode('templatefile')->defaultValue('')->end()->end()->end()->end()->end()->arrayNode('ogone')->children()->scalarNode('name')->defaultValue('Ogone')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('ogone')->cannotBeEmpty()->end()->arrayNode('transformers')->children()->scalarNode('basket')->defaultValue('sonata.payment.transformer.basket')->cannotBeEmpty()->end()->scalarNode('order')->defaultValue('sonata.payment.transformer.order')->cannotBeEmpty()->end()->end()->end()->arrayNode('options')->children()->scalarNode('url_callback')->defaultValue('sonata_payment_callback')->cannotBeEmpty()->end()->scalarNode('url_return_ko')->defaultValue('sonata_payment_error')->cannotBeEmpty()->end()->scalarNode('url_return_ok')->defaultValue('sonata_payment_confirmation')->cannotBeEmpty()->end()->scalarNode('form_url')->isRequired()->cannotBeEmpty()->end()->scalarNode('catalog_url')->isRequired()->cannotBeEmpty()->end()->scalarNode('home_url')->isRequired()->cannotBeEmpty()->end()->scalarNode('pspid')->isRequired()->cannotBeEmpty()->end()->scalarNode('sha_key')->isRequired()->cannotBeEmpty()->end()->scalarNode('sha-out_key')->isRequired()->cannotBeEmpty()->end()->scalarNode('template')->defaultValue('SonataPaymentBundle:Payment:ogone.html.twig')->cannotBeEmpty()->end()->end()->end()->end()->end()->end()->end()->arrayNode('methods')->useAttributeAsKey('code')->prototype('scalar')->end()->end()->end();
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:20,代码来源:Configuration.php

示例3: addDeliverySection

 /**
  * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
  */
 private function addDeliverySection(ArrayNodeDefinition $node)
 {
     $node->validate()->ifTrue(function ($v) {
         foreach ($v['methods'] as $methodCode => $service) {
             if (null === $service || '' === $service) {
                 foreach ($v['services'] as $serviceConf) {
                     if ($methodCode === $serviceConf['code']) {
                         break 2;
                     }
                 }
                 return true;
             }
         }
         return false;
     })->thenInvalid('Custom delivery methods require a service id. Provided delivery methods need to be configured with their method code as key.')->end()->children()->arrayNode('services')->children()->arrayNode('free_address_required')->children()->scalarNode('name')->defaultValue('free_address_required')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('free_address_required')->cannotBeEmpty()->end()->scalarNode('priority')->defaultValue(10)->cannotBeEmpty()->end()->end()->end()->arrayNode('free_address_not_required')->children()->scalarNode('name')->defaultValue('free_address_not_required')->cannotBeEmpty()->end()->scalarNode('code')->defaultValue('free_address_not_required')->cannotBeEmpty()->end()->scalarNode('priority')->defaultValue(10)->cannotBeEmpty()->end()->end()->end()->end()->end()->arrayNode('methods')->useAttributeAsKey('code')->prototype('scalar')->end()->end()->end();
 }
开发者ID:kinkinweb,项目名称:lhvb,代码行数:19,代码来源:Configuration.php

示例4: buildRelationsTree

 /**
  * Builds relations config tree for given relation name.
  *
  * @param string $relationType
  *
  * @return ArrayNodeDefinition
  */
 private function buildRelationsTree($relationType)
 {
     $filter = new ArrayNodeDefinition($relationType);
     $filter->validate()->ifTrue(function ($v) {
         return empty($v['include']) && empty($v['exclude']);
     })->thenInvalid('Relation must have "include" or "exclude" fields specified.')->end()->validate()->ifTrue(function ($v) {
         return !empty($v['include']) && !empty($v['exclude']);
     })->thenInvalid('Relation must have only "include" or "exclude" fields specified.')->end()->children()->arrayNode('include')->beforeNormalization()->ifString()->then(function ($v) {
         return [$v];
     })->end()->prototype('scalar')->end()->end()->arrayNode('exclude')->beforeNormalization()->ifString()->then(function ($v) {
         return [$v];
     })->end()->prototype('scalar')->end()->end()->end();
     return $filter;
 }
开发者ID:vinhdrt,项目名称:FilterManagerBundle,代码行数:21,代码来源:Configuration.php

示例5: addValidatorValidation

 /**
  * Add validation to a validator key
  *
  * @param ArrayNodeDefinition $node
  */
 protected function addValidatorValidation(ArrayNodeDefinition $node)
 {
     $node->validate()->ifTrue(function ($value) {
         if (!is_array($value)) {
             return true;
         }
         // All key must be string. Used as alias for the validator service
         if (count(array_filter(array_keys($value), 'is_string')) != count($value)) {
             return true;
         }
         // All value must be array. Used as configuration for validator
         if (count(array_filter(array_values($value), 'is_array')) != count($value)) {
             return true;
         }
         return false;
     })->thenInvalid('Invalid validators configuration')->end();
 }
开发者ID:harpcio,项目名称:FileUploaderBundle,代码行数:22,代码来源:MainConfiguration.php

示例6: deleteChildIfEmpty

 /**
  * @param ArrayNodeDefinition $arrayNodeDefinition
  * @param $field
  */
 private function deleteChildIfEmpty(ArrayNodeDefinition $arrayNodeDefinition, $field)
 {
     $arrayNodeDefinition->validate()->ifTrue(function ($data) use($field) {
         return isset($data[$field]) && ([] === $data[$field] || '' === $data[$field]);
     })->then(function ($data) use($field) {
         unset($data[$field]);
         return $data;
     });
 }
开发者ID:vikey89,项目名称:Sylius,代码行数:13,代码来源:ThemeConfiguration.php

示例7: createValidationsNodeDefinition

 /**
  * Create a configuration node to define validations for a step (or pre-validation on a next state).
  *
  * @return ArrayNodeDefinition
  */
 private function createValidationsNodeDefinition()
 {
     $validatorSyntax = function (array $values) {
         foreach ($values as $value) {
             if (2 !== count($parts = explode(':', $value))) {
                 return true;
             }
         }
     };
     $validationsNode = new ArrayNodeDefinition('validations');
     $validationsNode->validate()->ifTrue(function ($value) use($validatorSyntax) {
         return is_array($value) && $validatorSyntax($value);
     })->thenInvalid('You must specify valid validation name as serviceId:method string')->end()->prototype('scalar')->end();
     return $validationsNode;
 }
开发者ID:absalonvaldes,项目名称:FreeAgentWorkflowBundle,代码行数:20,代码来源:Configuration.php


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