當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ArrayNodeDefinition::children方法代碼示例

本文整理匯總了PHP中Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::children方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayNodeDefinition::children方法的具體用法?PHP ArrayNodeDefinition::children怎麽用?PHP ArrayNodeDefinition::children使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition的用法示例。


在下文中一共展示了ArrayNodeDefinition::children方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: configure

 /**
  * Setups configuration for the extension.
  *
  * @param ArrayNodeDefinition $builder
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->children()->scalarNode("name")->defaultValue("emusehtml");
     $builder->children()->scalarNode("renderer")->defaultValue("behat2");
     $builder->children()->scalarNode("file_name")->defaultValue("generated");
     $builder->children()->scalarNode('output')->defaultValue('.');
 }
開發者ID:lifencolor,項目名稱:BehatHtmlFormatterPlugin,代碼行數:12,代碼來源:BehatHTMLFormatterExtension.php

示例2: configure

 /**
  * Setups configuration for the extension.
  *
  * @param ArrayNodeDefinition $builder
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $paths = $builder->children()->arrayNode('path')->children();
     foreach (array('resources', 'base') as $namespaceType) {
         $paths->scalarNode($namespaceType);
     }
     $builder->children()->variableNode('resource_map');
     $builder->children()->scalarNode('factory_class');
 }
開發者ID:peterfox,項目名稱:behat-resources-extension,代碼行數:14,代碼來源:ResourceExtension.php

示例3: configurePageObjectFactory

 /**
  * @param ArrayNodeDefinition $builder
  */
 private function configurePageObjectFactory(ArrayNodeDefinition $builder)
 {
     $factory = $builder->children()->arrayNode('factory');
     $factory->beforeNormalization()->ifString()->then(function ($v) {
         return array('id' => $v);
     })->end()->children()->scalarNode('id')->info('id of a page object factory service')->end()->scalarNode('class_name_resolver')->info('id of a class name resolver service for the default factory')->end()->arrayNode('page_parameters')->info('parameters passed from the factory when creating a page')->prototype('scalar')->end()->end()->end();
 }
開發者ID:icambridge,項目名稱:BehatPageObjectExtension,代碼行數:10,代碼來源:PageObjectExtension.php

示例4: addAclSection

 private function addAclSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode
         ->children()
             ->arrayNode('acl')
                 ->children()
                     ->scalarNode('connection')->end()
                     ->arrayNode('cache')
                         ->addDefaultsIfNotSet()
                         ->children()
                             ->scalarNode('id')->end()
                             ->scalarNode('prefix')->defaultValue('sf2_acl_')->end()
                         ->end()
                     ->end()
                     ->arrayNode('tables')
                         ->addDefaultsIfNotSet()
                         ->children()
                             ->scalarNode('class')->defaultValue('acl_classes')->end()
                             ->scalarNode('entry')->defaultValue('acl_entries')->end()
                             ->scalarNode('object_identity')->defaultValue('acl_object_identities')->end()
                             ->scalarNode('object_identity_ancestors')->defaultValue('acl_object_identity_ancestors')->end()
                             ->scalarNode('security_identity')->defaultValue('acl_security_identities')->end()
                         ->end()
                     ->end()
                     ->arrayNode('voter')
                         ->addDefaultsIfNotSet()
                         ->children()
                             ->booleanNode('allow_if_object_identity_unavailable')->defaultTrue()->end()
                         ->end()
                     ->end()
                 ->end()
             ->end()
         ->end()
     ;
 }
開發者ID:nacef,項目名稱:symfony,代碼行數:35,代碼來源:MainConfiguration.php

示例5: addDynamicSection

 private function addDynamicSection(ArrayNodeDefinition $root)
 {
     $root->children()->arrayNode('dynamic')->fixXmlConfig('controller_by_type', 'controllers_by_type')->fixXmlConfig('controller_by_class', 'controllers_by_class')->fixXmlConfig('template_by_class', 'templates_by_class')->fixXmlConfig('route_filter_by_id', 'route_filters_by_id')->fixXmlConfig('locale')->addDefaultsIfNotSet()->canBeEnabled()->children()->scalarNode('route_collection_limit')->defaultValue(0)->end()->scalarNode('generic_controller')->defaultNull()->end()->scalarNode('default_controller')->defaultNull()->end()->arrayNode('controllers_by_type')->useAttributeAsKey('type')->prototype('scalar')->end()->end()->arrayNode('controllers_by_class')->useAttributeAsKey('class')->prototype('scalar')->end()->end()->arrayNode('templates_by_class')->useAttributeAsKey('class')->prototype('scalar')->end()->end()->arrayNode('persistence')->addDefaultsIfNotSet()->validate()->ifTrue(function ($v) {
         return count(array_filter($v, function ($persistence) {
             return $persistence['enabled'];
         })) > 1;
     })->thenInvalid('Only one persistence layer can be enabled at the same time.')->end()->children()->arrayNode('phpcr')->addDefaultsIfNotSet()->canBeEnabled()->fixXmlConfig('route_basepath')->validate()->ifTrue(function ($v) {
         isset($v['route_basepath']) && isset($v['route_basepaths']);
     })->thenInvalid('Found values for both "route_basepath" and "route_basepaths", use "route_basepaths" instead.')->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['route_basepath']) && !is_array($v['route_basepath']);
     })->then(function ($v) {
         @trigger_error('The route_basepath setting is deprecated as of version 1.4 and will be removed in 2.0. Use route_basepaths instead.', E_USER_DEPRECATED);
         return $v;
     })->end()->children()->scalarNode('manager_name')->defaultNull()->end()->arrayNode('route_basepaths')->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->defaultValue(array('/cms/routes'))->end()->scalarNode('admin_basepath')->defaultNull()->end()->scalarNode('content_basepath')->defaultValue('/cms/content')->end()->enumNode('use_sonata_admin')->beforeNormalization()->ifString()->then(function ($v) {
         switch ($v) {
             case 'true':
                 return true;
             case 'false':
                 return false;
             default:
                 return $v;
         }
     })->end()->values(array(true, false, 'auto'))->defaultValue('auto')->end()->enumNode('enable_initializer')->beforeNormalization()->ifString()->then(function ($v) {
         switch ($v) {
             case 'true':
                 return true;
             case 'false':
                 return false;
             default:
                 return $v;
         }
     })->end()->values(array(true, false, 'auto'))->defaultValue('auto')->end()->end()->end()->arrayNode('orm')->addDefaultsIfNotSet()->canBeEnabled()->children()->scalarNode('manager_name')->defaultNull()->end()->end()->end()->end()->end()->scalarNode('uri_filter_regexp')->defaultValue('')->end()->scalarNode('route_provider_service_id')->end()->arrayNode('route_filters_by_id')->canBeUnset()->defaultValue(array())->useAttributeAsKey('id')->prototype('scalar')->end()->end()->scalarNode('content_repository_service_id')->end()->arrayNode('locales')->prototype('scalar')->end()->end()->integerNode('limit_candidates')->defaultValue(20)->end()->booleanNode('match_implicit_locale')->defaultValue(true)->end()->booleanNode('auto_locale_pattern')->defaultValue(false)->end()->scalarNode('url_generator')->defaultValue('cmf_routing.generator')->info('URL generator service ID')->end()->end()->end()->end();
 }
開發者ID:killerwolf,項目名稱:RoutingBundle,代碼行數:35,代碼來源:Configuration.php

示例6: addConnectionsSection

 /**
  * Adds connections definition.
  *
  * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
  */
 protected function addConnectionsSection(ArrayNodeDefinition $node)
 {
     $node->children()->scalarNode('default_connection')->info('Name of the default connection')->end()->arrayNode('connections')->info('Solr Search Engine connection configuration')->useAttributeAsKey('connection_name')->performNoDeepMerging()->prototype('array')->beforeNormalization()->ifTrue(function ($v) {
         return !empty($v['mapping']) && !is_array($v['mapping']);
     })->then(function ($v) {
         // If single endpoint is set for Content mapping, use it as default
         // mapping for Content index
         $v['mapping'] = array('default' => $v['mapping']);
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return empty($v['entry_endpoints']) && (!empty($v['mapping']['translations']) || !empty($v['mapping']['default']) || !empty($v['mapping']['main_translations']));
     })->then(function ($v) {
         $endpointSet = array();
         if (!empty($v['mapping']['translations'])) {
             $endpointSet = array_flip($v['mapping']['translations']);
         }
         if (!empty($v['mapping']['default'])) {
             $endpointSet[$v['mapping']['default']] = true;
         }
         if (!empty($v['mapping']['main_translations'])) {
             $endpointSet[$v['mapping']['main_translations']] = true;
         }
         $v['entry_endpoints'] = array_keys($endpointSet);
         return $v;
     })->end()->children()->arrayNode('entry_endpoints')->info("A set of entry endpoint names.\n\n" . 'If not set, mapping endpoints will be used.')->example(array('endpoint1', 'endpoint2'))->prototype('scalar')->end()->end()->arrayNode('mapping')->info('Defines a map of translation language codes and Solr ' . "endpoint names for Content index.\n\n" . 'Optionally, you can define default and main translations ' . 'endpoints. Default one will be used for a translation if it ' . 'is not explicitly mapped, and main translations will be used ' . "for indexing translations in the main languages.\n\n" . 'If single endpoint name is given, it will be used as a ' . 'shortcut to define the default endpoint.')->addDefaultsIfNotSet()->example(array(array('translations' => array('cro-HR' => 'endpoint1', 'eng-GB' => 'endpoint2'), 'default' => 'endpoint3', 'main_translations' => 'endpoint4')))->children()->arrayNode('translations')->normalizeKeys(false)->useAttributeAsKey('language_code')->info('A map of translation language codes and Solr ' . 'endpoint names for Content index.')->example(array('cro-HR' => 'endpoint1', 'eng-GB' => 'endpoint2'))->prototype('scalar')->end()->end()->scalarNode('default')->defaultNull()->info('Default endpoint will be used for indexing ' . 'documents of a translation that is not explicitly ' . "mapped.\n\n" . 'This setting is optional.')->end()->scalarNode('main_translations')->defaultNull()->info('Main translations endpoint will be used to index ' . "documents of translations in the main languages\n\n" . 'This setting is optional. Use it to reduce the ' . 'number of Solr endpoints that the query is ' . 'distributed to when using always available fallback ' . 'or searching only on the main languages.')->end()->end()->end()->end()->end()->end();
 }
開發者ID:joaoinacio,項目名稱:ezplatform-solr-search-engine,代碼行數:31,代碼來源:Configuration.php

示例7: addTriggerNodes

 /**
  * @param ArrayNodeDefinition $nodeDefinition
  * @return ArrayNodeDefinition
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function addTriggerNodes(ArrayNodeDefinition $nodeDefinition)
 {
     $nodeDefinition->children()->enumNode('event')->defaultNull()->values(ProcessTrigger::getAllowedEvents())->end()->scalarNode('field')->defaultNull()->end()->integerNode('priority')->defaultValue(Job::PRIORITY_DEFAULT)->end()->booleanNode('queued')->defaultFalse()->end()->scalarNode('time_shift')->defaultNull()->validate()->always(function ($value) {
         // if value is an integer value
         $integerValue = filter_var($value, FILTER_VALIDATE_INT);
         if (false !== $integerValue) {
             return $integerValue;
         }
         // if value is DateInterval spec
         try {
             return ProcessTrigger::convertDateIntervalToSeconds(new \DateInterval($value));
         } catch (\Exception $e) {
             throw new \LogicException(sprintf('Time shift "%s" is not compatible with DateInterval', $value));
         }
     })->end()->end()->scalarNode('cron')->defaultNull()->validate()->always(function ($value) {
         if ($value !== null) {
             // validate expression string
             CronExpression::factory($value);
         }
         return $value;
     })->end()->end()->end()->validate()->always(function ($data) {
         if ($data['event'] && $data['cron']) {
             throw new \LogicException('Only one child node "event" or "cron" must be configured.');
         }
         if ($data['cron'] && ($data['field'] || $data['queued'] || $data['time_shift'])) {
             throw new \LogicException('Nodes "field", "queued" and "time_shift" are only allowed with event node.');
         }
         if ($data['field'] && $data['event'] !== ProcessTrigger::EVENT_UPDATE) {
             throw new \LogicException('Field is only allowed for update event');
         }
         return $data;
     })->end();
     return $nodeDefinition;
 }
開發者ID:startupz,項目名稱:platform-1,代碼行數:41,代碼來源:ProcessTriggerConfiguration.php

示例8: addFiltersSection

 /**
  * @param ArrayNodeDefinition $rootNode
  */
 private function addFiltersSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->children()->arrayNode('filters')->validate()->ifTrue(function ($v) {
         $v = array_filter($v);
         return empty($v);
     })->thenInvalid('At least single filter must be configured.')->end()->children()->append($this->buildFilterTree('choice'))->append($this->buildFilterTree('multi_choice'))->append($this->buildFilterTree('match'))->append($this->buildFilterTree('fuzzy'))->append($this->buildFilterTree('sort'))->append($this->buildFilterTree('pager'))->append($this->buildFilterTree('document_field'))->append($this->buildFilterTree('range'))->append($this->buildFilterTree('date_range'))->append($this->buildFilterTree('variant'))->end()->end()->end();
 }
開發者ID:vinhdrt,項目名稱:FilterManagerBundle,代碼行數:10,代碼來源:Configuration.php

示例9: setupTree

 /**
  * Configure the root node
  *
  * @param ArrayNodeDefinition $rootNode
  */
 protected function setupTree(ArrayNodeDefinition $rootNode)
 {
     $templateValidation = function ($value) {
         if (is_string($value)) {
             return $value;
         }
         throw new \InvalidArgumentException(sprintf('Status templates must be strings, "%s" found', $value));
     };
     $checkForNumeric = function ($value) {
         if (is_numeric($value)) {
             return $value;
         }
         throw new \InvalidArgumentException(sprintf('Status code for error templates must be numeric, "%s" found', $value));
     };
     $checkForNumericKeys = function (array $value) {
         foreach ($value as $code => $template) {
             if (!is_numeric($code)) {
                 throw new \InvalidArgumentException(sprintf('Status codes for error templates must be numeric, "%s" found', $code));
             }
         }
         return $value;
     };
     $rootNode->children()->arrayNode('error_templates')->info('Error templates setup')->canBeEnabled()->children()->scalarNode('default')->info('Default template for exceptions')->defaultValue('Exception:error.html.twig')->validate()->always($templateValidation)->end()->end()->arrayNode('by_code')->info('Specific template by status code')->example('{ 404: Exception:error.html.twig }')->useAttributeAsKey('name')->prototype('scalar')->validate()->ifTrue(function ($value) {
         return null !== $value;
     })->then($templateValidation)->end()->end()->validate()->always($checkForNumericKeys)->end()->end()->scalarNode('fallback')->info('Default status code for non-http exceptions')->defaultFalse()->treatTrueLike(Response::HTTP_INTERNAL_SERVER_ERROR)->validate()->always($checkForNumeric)->end()->end()->end()->end()->end();
 }
開發者ID:elcodi,項目名稱:bamboo,代碼行數:31,代碼來源:Configuration.php

示例10: append

 /**
  *
  * @param ArrayNodeDefinition $root     Config root node
  * @param array               $settings
  */
 public static function append(ArrayNodeDefinition $root, $settings)
 {
     $builder = new TreeBuilder();
     $node = $builder->root('settings')->addDefaultsIfNotSet()->children()->scalarNode(self::RESOLVED_KEY)->defaultTrue()->end();
     foreach ($settings as $name => $setting) {
         $child = $node->arrayNode($name)->addDefaultsIfNotSet()->children();
         if (isset($setting['type']) && in_array($setting['type'], array('scalar', 'boolean', 'array'))) {
             $type = $setting['type'];
         } else {
             $type = 'scalar';
         }
         switch ($type) {
             case 'scalar':
                 $child->scalarNode('value')->defaultValue($setting['value']);
                 break;
             case 'boolean':
                 $child->booleanNode('value')->defaultValue((bool) $setting['value']);
                 break;
             case 'array':
                 $child->arrayNode('value')->treatNullLike(array())->prototype('scalar')->end()->defaultValue(isset($setting['value']) ? $setting['value'] : array());
                 break;
         }
         $child->scalarNode('scope')->defaultValue(isset($setting['scope']) ? $setting['scope'] : 'app');
     }
     $root->children()->append($node->end());
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:31,代碼來源:SettingsBuilder.php

示例11: addCaptchaConfigSection

 public function addCaptchaConfigSection(ArrayNodeDefinition $rootNode, $page, array $captchaConfig)
 {
     $captchaId = isset($captchaConfig['captcha_id']) ? $captchaConfig['captcha_id'] : 'defaultCaptcha';
     $userInputId = isset($captchaConfig['user_input_id']) ? $captchaConfig['user_input_id'] : 'captchaCode';
     $captchaConfigFilePath = isset($captchaConfig['captcha_config_file_path']) ? $captchaConfig['captcha_config_file_path'] : null;
     $rootNode->children()->arrayNode($page)->children()->scalarNode('captcha_id')->defaultValue($captchaId)->end()->scalarNode('user_input_id')->defaultValue($userInputId)->end()->scalarNode('captcha_config_file_path')->defaultValue($captchaConfigFilePath)->end()->end()->end()->end();
 }
開發者ID:RubenCox,項目名稱:Symfony_Web-Mobile,代碼行數:7,代碼來源:Configuration.php

示例12: addSecuritySection

 private function addSecuritySection(ArrayNodeDefinition $node)
 {
     $supportedSecurityXFrameOptions = [null, 'deny', 'same-origin'];
     $node->children()->arrayNode('security')->addDefaultsIfNotSet()->children()->scalarNode('x_frame_options')->validate()->ifTrue(function ($value) use($supportedSecurityXFrameOptions) {
         return !(in_array($value, $supportedSecurityXFrameOptions) || filter_var($value, FILTER_VALIDATE_URL));
     })->thenInvalid('The x_frame_options option only allows values ' . json_encode($supportedSecurityXFrameOptions) . ' or an URI.')->end()->defaultValue(null)->end()->end()->end();
 }
開發者ID:gitter-badger,項目名稱:OAuth2ServerBundle,代碼行數:7,代碼來源:AuthorizationEndpointPlugin.php

示例13: addConfiguration

 /**
  * {@inheritDoc}
  */
 public function addConfiguration(ArrayNodeDefinition $builder)
 {
     $builder
         ->children()
             ->scalarNode('bucket')->isRequired()->cannotBeEmpty()->end()
             ->scalarNode('cache')->defaultValue(false)->end()
             ->scalarNode('acl')->defaultValue('public-read')->cannotBeEmpty()->end()
             ->scalarNode('cache_prefix')->defaultValue(null)->end()
             ->arrayNode('client_config')
                 ->isRequired()
                 ->useAttributeAsKey('key')
                 ->prototype('scalar')->end()
             ->end()
             /* @deprecated Use `get_options` instead */
             ->arrayNode('url_options')
                 ->useAttributeAsKey('key')
                 ->prototype('scalar')->end()
             ->end()
             ->arrayNode('get_options')
                 ->useAttributeAsKey('key')
                 ->prototype('scalar')->end()
             ->end()
             ->arrayNode('put_options')
                 ->useAttributeAsKey('key')
                 ->prototype('scalar')->end()
             ->end()
             ->arrayNode('proxies')
                 ->defaultValue(array())
                 ->prototype('scalar')->end()
             ->end()
         ->end()
     ;
 }
開發者ID:xxspartan16,項目名稱:BMS-Market,代碼行數:36,代碼來源:AwsS3ResolverFactory.php

示例14: testAppendingSomeNode

 public function testAppendingSomeNode()
 {
     $parent = new ArrayNodeDefinition('root');
     $child = new ScalarNodeDefinition('child');
     $parent->children()->scalarNode('foo')->end()->scalarNode('bar')->end()->end()->append($child);
     $this->assertCount(3, $this->getField($parent, 'children'));
     $this->assertTrue(in_array($child, $this->getField($parent, 'children')));
 }
開發者ID:Ener-Getick,項目名稱:symfony,代碼行數:8,代碼來源:ArrayNodeDefinitionTest.php

示例15: addCurrencySection

 /**
  * Parses the kitpages_cms.block config section
  * Example for yaml driver:
  * tbbc_money:
  *     currencies: ["USD", "EUR"]
  *     reference_currency: "EUR"
  *
  * @param ArrayNodeDefinition $node
  * @return void
  */
 private function addCurrencySection(ArrayNodeDefinition $node)
 {
     $node->children()->arrayNode('currencies')->prototype('scalar')->end()->end()->scalarNode('reference_currency')->isRequired()->cannotBeEmpty()->end()->booleanNode('enable_pair_history')->defaultValue(false)->end()->integerNode('decimals')->defaultValue(2)->min(0)->end()->scalarNode('storage')->cannotBeEmpty()->defaultValue('csv')->validate()->ifNotInArray(array('csv', 'doctrine'))->thenInvalid('Invalid storage "%s"')->end()->end()->scalarNode('ratio_provider')->cannotBeEmpty()->defaultValue('tbbc_money.ratio_provider.yahoo_finance')->end()->arrayNode('templating')->addDefaultsIfNotSet()->children()->arrayNode('engines')->isRequired()->requiresAtLeastOneElement()->example(array('twig'))->beforeNormalization()->ifTrue(function ($v) {
         return !is_array($v);
     })->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->validate()->ifNotInArray(array('twig', 'php'))->thenInvalid('Only "twig" and "php" engines are supported.')->end()->end()->defaultValue(array('twig'))->end()->end()->end()->end();
 }
開發者ID:lakhman,項目名稱:TbbcMoneyBundle,代碼行數:18,代碼來源:Configuration.php


注:本文中的Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::children方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。