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


PHP ArrayNodeDefinition::addDefaultsIfNotSet方法代码示例

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


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

示例1: defaultTransport

 /**
  * @test if transport is not set default (first) is used
  */
 public function defaultTransport()
 {
     $this->root1->addDefaultsIfNotSet()->children()->scalarNode('param1')->defaultValue('value1')->end()->scalarNode('param2')->defaultValue('value2')->end()->end();
     $config = $this->processSection(['sub1' => [], 'sub2' => []]);
     $transport = ['type' => 'transport1', 'parameters' => ['param1' => 'value1', 'param2' => 'value2']];
     $this->assertEquals($transport, $config['sub1']['transport']);
     $this->assertEquals($transport, $config['sub2']['transport']);
 }
开发者ID:coyl,项目名称:EventBandSymfonyBundle,代码行数:11,代码来源:ConsumerConfigurationTest.php

示例2: getDefaultsSection

 private function getDefaultsSection()
 {
     $node = new ArrayNodeDefinition('defaults');
     $node->addDefaultsIfNotSet();
     $this->appendPrototypedConfiguration($node);
     return $node;
 }
开发者ID:alchemy-fr,项目名称:symfony-cors,代码行数:7,代码来源:CorsConfiguration.php

示例3: configure

 /**
  * @param ArrayNodeDefinition $builder
  *
  * @return null
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->addDefaultsIfNotSet()->children()->arrayNode('fixtures')->beforeNormalization()->ifTrue(function ($v) {
         return is_scalar($v);
     })->then(function ($v) {
         return array('default' => array('app'), 'key_paths' => array('app' => $v));
     })->end()->validate()->ifTrue(function ($v) {
         foreach ($v['default'] as $default) {
             if (!array_key_exists($default, $v['key_paths'])) {
                 return true;
             }
         }
     })->thenInvalid("You can't define a default which is not present in key_paths.")->end()->children()->arrayNode('default')->beforeNormalization()->ifTrue(function ($v) {
         return is_scalar($v);
     })->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->arrayNode('key_paths')->useAttributeAsKey('key_path')->validate()->ifTrue(function ($v) {
         return array_key_exists(FixtureStack::DEFAULT_KEY, $v);
     })->thenInvalid('You cannot add a key_path with key “' . FixtureStack::DEFAULT_KEY . '“, this is a reserved word.')->end()->prototype('scalar')->end()->end()->end()->end()->scalarNode('lifetime')->end()->arrayNode('faker')->addDefaultsIfNotSet()->children()->scalarNode('locale')->defaultValue('en_US')->end()->arrayNode('providers')->beforeNormalization()->always(function ($v) {
         return array_map(function ($class) {
             return new $class();
         }, $v);
     })->end()->prototype('variable')->end()->end()->end()->end()->arrayNode('adapters')->addDefaultsIfNotSet()->children()->arrayNode('elastica')->children()->scalarNode('fixture_class')->defaultValue('Rezzza\\AliceExtension\\Fixture\\ElasticaFixture')->cannotBeEmpty()->end()->scalarNode('index_service')->cannotBeEmpty()->end()->arrayNode('mapping')->prototype('scalar')->end()->end()->end()->end()->arrayNode('orm')->addDefaultsIfNotSet()->children()->scalarNode('fixture_class')->defaultValue('Rezzza\\AliceExtension\\Fixture\\ORMFixture')->cannotBeEmpty()->end()->end()->end()->end()->end()->arrayNode('faker')->addDefaultsIfNotSet()->children()->scalarNode('locale')->defaultValue('en_US')->end()->arrayNode('providers')->beforeNormalization()->always(function ($v) {
         return array_map(function ($class) {
             return new $class();
         }, $v);
     })->end()->prototype('variable')->end()->end()->end()->end()->end();
 }
开发者ID:shouze,项目名称:alice-extension,代码行数:33,代码来源:Extension.php

示例4: addConfiguration

 public function addConfiguration(ArrayNodeDefinition $pluginNode)
 {
     $pluginNode->addDefaultsIfNotSet()->children()->scalarNode('template_engine')->defaultValue('twig')->cannotBeEmpty()->end()->end();
     $this->addFormSection($pluginNode);
     $this->addOptionSection($pluginNode);
     $this->addSecuritySection($pluginNode);
 }
开发者ID:gitter-badger,项目名称:OAuth2ServerBundle,代码行数:7,代码来源:AuthorizationEndpointPlugin.php

示例5: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $boolFilter = function ($v) {
         $filtered = filter_var($v, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
         return null === $filtered ? $v : $filtered;
     };
     $builder->addDefaultsIfNotSet()->children()->arrayNode('kernel')->addDefaultsIfNotSet()->children()->scalarNode('bootstrap')->defaultValue('app/autoload.php')->end()->scalarNode('path')->defaultValue('app/Application.php')->end()->scalarNode('class')->defaultValue(null)->end()->scalarNode('env')->defaultValue('test')->end()->booleanNode('debug')->beforeNormalization()->ifString()->then($boolFilter)->end()->defaultTrue()->end()->booleanNode('testSession')->defaultTrue()->end()->end()->end()->end()->end();
 }
开发者ID:tabbi89,项目名称:Behat-Silex-Extension,代码行数:11,代码来源:SilexExtension.php

示例6: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $boolFilter = function ($v) {
         $filtered = filter_var($v, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
         return null === $filtered ? $v : $filtered;
     };
     $builder->addDefaultsIfNotSet()->children()->scalarNode('client')->defaultValue('Symfony\\Bundle\\FrameworkBundle\\Client')->end()->arrayNode('kernel')->addDefaultsIfNotSet()->children()->scalarNode('bootstrap')->defaultValue('app/autoload.php')->end()->scalarNode('path')->defaultValue('app/AppKernel.php')->end()->scalarNode('class')->defaultValue('AppKernel')->end()->scalarNode('env')->defaultValue('test')->end()->booleanNode('debug')->beforeNormalization()->ifString()->then($boolFilter)->end()->defaultTrue()->end()->end()->end()->arrayNode('context')->addDefaultsIfNotSet()->children()->scalarNode('path_suffix')->defaultValue('Features')->end()->scalarNode('class_suffix')->defaultValue('Features\\Context\\FeatureContext')->end()->end()->end()->end()->end();
 }
开发者ID:gkawka,项目名称:Symfony2Extension,代码行数:11,代码来源:Symfony2Extension.php

示例7: configure

 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $boolFilter = function ($v) {
         $filtered = filter_var($v, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE);
         return null === $filtered ? $v : $filtered;
     };
     $builder->addDefaultsIfNotSet()->children()->arrayNode('client')->addDefaultsIfNotSet()->children()->scalarNode('url')->defaultValue('http://localhost')->end()->scalarNode('port')->defaultValue('1080')->end()->end()->end()->booleanNode('purge_before_scenario')->beforeNormalization()->ifString()->then($boolFilter)->end()->defaultTrue()->end()->scalarNode('mailcatcher_client')->defaultValue(self::DEFAULT_CLIENT_ID)->end()->scalarNode('mailcatcher_connection')->defaultValue(self::CONNECTION_GUZZLE_ID)->end()->end()->end();
 }
开发者ID:kibao,项目名称:behat-mailcatcher-extension,代码行数:11,代码来源:Extension.php

示例8: setModelConfig

 protected function setModelConfig(ArrayNodeDefinition $nodeDefinition, array $config, $defaultRepositoryClass = null)
 {
     $childrenNode = $nodeDefinition->addDefaultsIfNotSet()->children();
     $childrenNode->scalarNode('default_repository')->defaultValue($defaultRepositoryClass)->end();
     $classesNode = $childrenNode->arrayNode('classes');
     foreach ($config as $model => $modelProperties) {
         $classesNode->addDefaultsIfNotSet()->children()->arrayNode($model)->addDefaultsIfNotSet()->children()->scalarNode('default_model')->defaultValue(@$modelProperties['default_class'] ?: $modelProperties['class'])->end()->scalarNode('model')->defaultValue($modelProperties['class'])->end()->scalarNode('repository')->defaultValue(@$modelProperties['repository'])->end()->end()->end()->end();
     }
 }
开发者ID:webility,项目名称:entity-resource-bundle,代码行数:9,代码来源:ResourcesConfiguration.php

示例9: getCapabilitiesNode

 protected function getCapabilitiesNode()
 {
     $node = new ArrayNodeDefinition('capabilities');
     $node->addDefaultsIfNotSet()->normalizeKeys(false)->children()->scalarNode('browserName')->defaultValue('firefox')->end()->scalarNode('version')->defaultValue('21')->end()->scalarNode('platform')->defaultValue('ANY')->end()->scalarNode('browserVersion')->defaultValue('9')->end()->scalarNode('browser')->defaultValue('firefox')->end()->scalarNode('ignoreZoomSetting')->defaultValue('false')->end()->scalarNode('name')->defaultValue('Behat feature suite')->end()->scalarNode('deviceOrientation')->defaultValue('portrait')->end()->scalarNode('deviceType')->defaultValue('tablet')->end()->booleanNode('javascriptEnabled')->end()->booleanNode('databaseEnabled')->end()->booleanNode('locationContextEnabled')->end()->booleanNode('applicationCacheEnabled')->end()->booleanNode('browserConnectionEnabled')->end()->booleanNode('webStorageEnabled')->end()->booleanNode('rotatable')->end()->booleanNode('acceptSslCerts')->end()->booleanNode('nativeEvents')->end()->arrayNode('proxy')->children()->scalarNode('proxyType')->end()->scalarNode('proxyAuthconfigUrl')->end()->scalarNode('ftpProxy')->end()->scalarNode('httpProxy')->end()->scalarNode('sslProxy')->end()->end()->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->arrayNode('firefox')->children()->scalarNode('profile')->validate()->ifTrue(function ($v) {
         return !file_exists($v);
     })->thenInvalid('Cannot find profile zip file %s')->end()->end()->scalarNode('binary')->end()->end()->end()->arrayNode('chrome')->children()->arrayNode('switches')->prototype('scalar')->end()->end()->scalarNode('binary')->end()->arrayNode('extensions')->prototype('scalar')->end()->end()->end()->end()->arrayNode('extra_capabilities')->info('Custom capabilities merged with the known ones')->normalizeKeys(false)->useAttributeAsKey('name')->prototype('variable')->end()->end()->end();
     return $node;
 }
开发者ID:xxspartan16,项目名称:BMS-Market,代码行数:10,代码来源:Selenium2Factory.php

示例10: addRoles

 private function addRoles(ArrayNodeDefinition $node)
 {
     $node->addDefaultsIfNotSet()->children()->arrayNode('roles')->useAttributeAsKey('name')->prototype('array')->children()->booleanNode('is_default')->defaultFalse()->end()->arrayNode('handler')->canBeUnset()->children()->scalarNode('cart')->cannotBeEmpty()->end()->scalarNode('item')->cannotBeEmpty()->end()->end()->end()->arrayNode('controller')->children()->scalarNode('cart')->cannotBeEmpty()->end()->scalarNode('item')->cannotBeEmpty()->end()->end()->end()->scalarNode('form')->end()->scalarNode('strategy')->end()->scalarNode('fallback_strategy')->end()->end()->validate()->ifTrue(function ($v) {
         return !isset($v['form']) && !isset($v['handler']['cart']);
     })->thenInvalid('You need to specify or the form or the cart handler.')->end()->end()->isRequired()->cannotBeEmpty()->validate()->ifTrue(function ($v) {
         return count($v) < 1;
     })->thenInvalid('You need to specify at least one role.')->end()->validate()->ifTrue(function ($roles) {
         $counter = 0;
         foreach ($roles as $role) {
             $counter += isset($role['is_default']) && $role['is_default'] ? 1 : 0;
         }
         return $counter > 1;
     })->thenInvalid('Multiple `is_default` defined.')->end()->end();
 }
开发者ID:sfraoua,项目名称:CartBundle,代码行数:14,代码来源:Configuration.php

示例11: configureRouter

 private function configureRouter(ArrayNodeDefinition $root)
 {
     $root->addDefaultsIfNotSet();
     $root->treatNullLike(['endpoints' => []]);
     /** @var ArrayNodeDefinition $proto */
     $endpoints = $root->children()->arrayNode('endpoints');
     $proto = $endpoints->prototype('array');
     $proto->append((new ScalarNodeDefinition('path'))->isRequired()->example('/')->cannotBeEmpty()->info('Endpoint URI'));
     $proto->append((new ArrayNodeDefinition('resources'))->beforeNormalization()->ifNull()->then(function () {
         return [];
     })->ifString()->then(function ($v) {
         return [$v];
     })->end()->prototype('scalar')->end()->example('rpc.yml')->info('Route definitions'));
     $proto->append(new VariableNodeDefinition('defaults'));
     $proto->append((new VariableNodeDefinition('context'))->beforeNormalization()->ifString()->then(function ($v) {
         return [$v];
     })->end()->defaultValue(['Default'])->info('Endpoint-wide context')->example(['Default']));
     $endpoints->useAttributeAsKey('name');
     $proto->addDefaultsIfNotSet();
 }
开发者ID:bankiru,项目名称:rpc-server-bundle,代码行数:20,代码来源:Configuration.php

示例12: configure

 /**
  * Setups configuration for the extension.
  *
  * @param ArrayNodeDefinition $builder
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->addDefaultsIfNotSet()->children()->scalarNode('pattern')->defaultValue('/placeholder\\(([a-zA-Z0-9_\\.\\-]+)\\)/')->info('All values that match PATTERN will be try to transform.')->end()->arrayNode('defaults')->prototype('scalar')->end();
 }
开发者ID:timitao,项目名称:behatplaceholderextension,代码行数:9,代码来源:Extension.php

示例13: addConfiguration

 /**
  * {@inheritdoc}
  */
 public function addConfiguration(ArrayNodeDefinition $pluginNode)
 {
     $pluginNode->addDefaultsIfNotSet()->children()->scalarNode('policy')->defaultValue('none')->info('Policy applied if no scope is requested by the client (default "none").')->end()->arrayNode('available_scope')->useAttributeAsKey('name')->treatNullLike([])->prototype('scalar')->end()->info('A list of scopes supported by this server (optional).')->end()->end();
 }
开发者ID:spomky-labs,项目名称:oauth2-server-bundle,代码行数:7,代码来源:ScopeManagerPlugin.php

示例14: addUserSection

 /**
  *
  * @access private
  * @param  \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
  * @return \CCDNUser\AdminBundle\DependencyInjection\Configuration
  */
 private function addUserSection(ArrayNodeDefinition $node)
 {
     $node->addDefaultsIfNotSet()->canBeUnset()->children()->arrayNode('account')->addDefaultsIfNotSet()->canBeUnset()->children()->arrayNode('show_newest_users')->addDefaultsIfNotSet()->canBeUnset()->children()->scalarNode('layout_template')->defaultValue($this->defaultValueLayoutTemplate)->end()->scalarNode('member_since_datetime_format')->defaultValue('d-m-Y - H:i')->end()->end()->end()->arrayNode('show_user')->addDefaultsIfNotSet()->canBeUnset()->children()->scalarNode('layout_template')->defaultValue($this->defaultValueLayoutTemplate)->end()->scalarNode('member_since_datetime_format')->defaultValue('d-m-Y - H:i')->end()->end()->end()->arrayNode('edit_user_account')->addDefaultsIfNotSet()->canBeUnset()->children()->scalarNode('layout_template')->defaultValue($this->defaultValueLayoutTemplate)->end()->scalarNode('form_theme')->defaultValue($this->defaultValueFormTheme)->end()->end()->end()->end()->end()->end();
     return $this;
 }
开发者ID:moave,项目名称:CCDNUserAdminBundle,代码行数:11,代码来源:Configuration.php

示例15: addServiceSection

 private function addServiceSection(ArrayNodeDefinition $node)
 {
     $node->addDefaultsIfNotSet()->children()->arrayNode('service')->addDefaultsIfNotSet()->children()->scalarNode('storage')->defaultValue('fos_oauth_server.storage.default')->cannotBeEmpty()->end()->scalarNode('user_provider')->defaultValue(true)->end()->scalarNode('scope_page')->defaultNull()->end()->scalarNode('client_manager')->defaultValue('fos_oauth_server.client_manager.default')->end()->scalarNode('access_token_manager')->defaultValue('fos_oauth_server.access_token_manager.default')->end()->scalarNode('refresh_token_manager')->defaultValue('fos_oauth_server.refresh_token_manager.default')->end()->scalarNode('auth_code_manager')->defaultValue('fos_oauth_server.auth_code_manager.default')->end()->arrayNode('options')->useAttributeAsKey('key')->treatNullLike(array())->prototype('scalar')->end()->end()->end()->end()->end()->end();
 }
开发者ID:lutskanu,项目名称:FOSOAuthServerBundle,代码行数:4,代码来源:Configuration.php


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