fixXmlConfig() public method

Sets a normalization rule for XML configurations.
public fixXmlConfig ( string $singular, string $plural = null ) : ArrayNodeDefinition
$singular string The key to remap
$plural string The plural of the key for irregular plurals
return ArrayNodeDefinition
コード例 #1
0
 private function addPostFilterSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode
         ->fixXmlConfig('post_filter')
         ->children()
             ->arrayNode('post_filters')
                 ->canBeUnset()
                 ->useAttributeAsKey('name')
                 ->prototype('array')    
                     ->fixXmlConfig('param')
                     ->children()
                          ->scalarNode('class')->end()
                          ->arrayNode('params')
                             ->beforeNormalization()
                                ->ifTrue(function($v){ return !is_array($v); })
                                ->then(function($v){ return array($v); })
                             ->end()
                             ->prototype('scalar')->end()
                         ->end()
                     ->end()
                 ->end()
             ->end()
         ->end()
     ->end();	
 }
コード例 #2
0
 /**
  * @param ArrayNodeDefinition $root
  */
 private function generateConfiguration(ArrayNodeDefinition $root)
 {
     $root->fixXmlConfig('exception')->children()->arrayNode('exceptions')->requiresAtLeastOneElement()->useAttributeAsKey('name')->normalizeKeys(false)->prototype('array')->children()->scalarNode('code')->end()->booleanNode('expose_message')->defaultValue('%kernel.debug%')->end()->end()->beforeNormalization()->ifTrue(function ($v) {
         return is_numeric($v);
     })->then(function ($v) {
         return ['code' => $v];
     })->end()->end()->end()->scalarNode('priority')->defaultValue(0)->end()->end();
 }
コード例 #3
0
 /**
  * Adds the configuration for the "indexes" key
  */
 private function addIndexesSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('index')->children()->arrayNode('indexes')->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('index_name')->end()->scalarNode('client')->end()->scalarNode('finder')->treatNullLike(true)->defaultFalse()->end()->arrayNode('type_prototype')->children()->scalarNode('index_analyzer')->end()->scalarNode('search_analyzer')->end()->arrayNode('persistence')->validate()->ifTrue(function ($v) {
         return isset($v['driver']) && 'propel' === $v['driver'] && isset($v['listener']);
     })->thenInvalid('Propel doesn\'t support listeners')->ifTrue(function ($v) {
         return isset($v['driver']) && 'propel' === $v['driver'] && isset($v['repository']);
     })->thenInvalid('Propel doesn\'t support the "repository" parameter')->end()->children()->scalarNode('driver')->validate()->ifNotInArray($this->supportedDrivers)->thenInvalid('The driver %s is not supported. Please choose one of ' . json_encode($this->supportedDrivers))->end()->end()->scalarNode('identifier')->defaultValue('id')->end()->arrayNode('provider')->children()->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()->scalarNode('batch_size')->defaultValue(100)->end()->scalarNode('clear_object_manager')->defaultTrue()->end()->scalarNode('service')->end()->end()->end()->arrayNode('listener')->children()->scalarNode('insert')->defaultTrue()->end()->scalarNode('update')->defaultTrue()->end()->scalarNode('delete')->defaultTrue()->end()->scalarNode('service')->end()->variableNode('is_indexable_callback')->defaultNull()->end()->end()->end()->arrayNode('finder')->children()->scalarNode('service')->end()->end()->end()->arrayNode('elastica_to_model_transformer')->addDefaultsIfNotSet()->children()->scalarNode('hydrate')->defaultTrue()->end()->scalarNode('ignore_missing')->defaultFalse()->end()->scalarNode('query_builder_method')->defaultValue('createQueryBuilder')->end()->scalarNode('service')->end()->end()->end()->arrayNode('model_to_elastica_transformer')->addDefaultsIfNotSet()->children()->scalarNode('service')->end()->end()->end()->end()->end()->end()->end()->variableNode('settings')->defaultValue(array())->end()->end()->append($this->getTypesNode())->end()->end()->end();
 }
コード例 #4
0
 /**
  * Add resolvers section
  *
  * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node
  * @param array $factories
  */
 protected function addResolversSection(ArrayNodeDefinition $node, array $factories)
 {
     $resolverNodeBuilder = $node->fixXmlConfig('resolver')->children()->arrayNode('resolvers')->useAttributeAsKey('name')->prototype('array')->performNoDeepMerging()->children();
     foreach ($factories as $name => $factory) {
         $factoryNode = $resolverNodeBuilder->arrayNode($name)->canBeUnset();
         $factory->addConfiguration($factoryNode);
     }
 }
コード例 #5
0
ファイル: Configuration.php プロジェクト: polisys/Sylius
 /**
  * @param ArrayNodeDefinition $rootNode
  */
 private function addSourcesConfiguration(ArrayNodeDefinition $rootNode)
 {
     $sourcesNodeBuilder = $rootNode->fixXmlConfig('source')->children()->arrayNode('sources')->children();
     foreach ($this->configurationSourceFactories as $sourceFactory) {
         $sourceNode = $sourcesNodeBuilder->arrayNode($sourceFactory->getName())->canBeEnabled();
         $sourceFactory->buildConfiguration($sourceNode);
     }
 }
コード例 #6
0
ファイル: Configuration.php プロジェクト: geoffreytran/zym
 private function addThemeMapSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('rule', 'theme_map')->children()->arrayNode('theme_map')->cannotBeOverwritten()->prototype('array')->children()->scalarNode('requires_channel')->defaultNull()->end()->scalarNode('path')->defaultNull()->info('use the urldecoded format')->example('^/path to resource/')->end()->scalarNode('host')->defaultNull()->end()->scalarNode('ip')->defaultNull()->end()->arrayNode('methods')->beforeNormalization()->ifString()->then(function ($v) {
         return preg_split('/\\s*,\\s*/', $v);
     })->end()->prototype('scalar')->end()->end()->end()->children()->scalarNode('theme')->end()->end()->fixXmlConfig('role')->children()->arrayNode('roles')->beforeNormalization()->ifString()->then(function ($v) {
         return preg_split('/\\s*,\\s*/', $v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->end();
 }
コード例 #7
0
 protected function addProvidersNode(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('provider')->children()->arrayNode('providers')->isRequired()->requiresAtLeastOneElement()->prototype('scalar')->end()->end()->end();
     foreach ($this->factories as $name => $factory) {
         $factoryNode = $rootNode->children()->arrayNode($name)->canBeUnset();
         $factory->addConfiguration($factoryNode);
     }
     return $rootNode;
 }
コード例 #8
0
 /**
  * Add event store section to configuration tree
  *
  * @link https://github.com/prooph/event-store
  *
  * @param ArrayNodeDefinition $node
  */
 private function addEventStoreSection(ArrayNodeDefinition $node)
 {
     $treeBuilder = new TreeBuilder();
     $repositoriesNode = $treeBuilder->root('repositories');
     /** @var $repositoriesNode ArrayNodeDefinition */
     $repositoryNode = $repositoriesNode->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array');
     $repositoryNode->children()->scalarNode('repository_class')->end()->scalarNode('aggregate_type')->end()->scalarNode('aggregate_translator')->end()->scalarNode('snapshot_store')->defaultValue(null)->end()->scalarNode('stream_name')->defaultValue(null)->end()->booleanNode('one_stream_per_aggregate')->defaultValue(false)->end()->end();
     $node->fixXmlConfig('store', 'stores')->children()->arrayNode('stores')->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array')->fixXmlConfig('repository', 'repositories')->children()->scalarNode('event_emitter')->defaultValue('prooph_event_store.action_event_emitter')->end()->scalarNode('adapter')->end()->append($repositoriesNode)->end()->end();
 }
コード例 #9
0
 private function addMappingsSection(ArrayNodeDefinition $node)
 {
     $defaults = self::getMappingDefaults();
     // @formatter:off
     /* @noinspection PhpUndefinedMethodInspection */
     $node->fixXmlConfig('mapping')->children()->arrayNode('mappings')->useAttributeAsKey('name')->prototype('array')->beforeNormalization()->ifString()->then(function ($value) {
         return ['storage' => $value];
     })->end()->addDefaultsIfNotSet()->children()->scalarNode('file_getter')->defaultValue($defaults['file_getter'])->end()->scalarNode('file_setter')->defaultValue($defaults['file_setter'])->end()->scalarNode('uri_setter')->defaultValue($defaults['uri_setter'])->end()->scalarNode('file_info_setter')->defaultValue($defaults['file_info_setter'])->end()->scalarNode('fs_prefix')->defaultValue($defaults['fs_prefix'])->end()->scalarNode('uri_prefix')->defaultValue($defaults['uri_prefix'])->end()->scalarNode('fs_adapter')->defaultValue($defaults['fs_adapter'])->end()->scalarNode('naming_strategy')->defaultValue($defaults['naming_strategy'])->end()->scalarNode('delete_old_file')->defaultValue($defaults['delete_old_file'])->end()->scalarNode('delete_on_remove')->defaultValue($defaults['delete_on_remove'])->end()->scalarNode('inject_uri_on_load')->defaultValue($defaults['inject_uri_on_load'])->end()->scalarNode('inject_file_info_on_load')->defaultValue($defaults['inject_file_info_on_load'])->end()->end()->end()->end()->end();
     return $node;
 }
コード例 #10
0
 /**
  * Adds the snc_redis.clients configuration
  *
  * @param ArrayNodeDefinition $rootNode
  */
 private function addClientsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('client')->children()->arrayNode('clients')->isRequired()->requiresAtLeastOneElement()->useAttributeAsKey('alias', false)->prototype('array')->fixXmlConfig('connection')->children()->arrayNode('connections')->isRequired()->beforeNormalization()->ifString()->then(function ($v) {
         return (array) $v;
     })->end()->prototype('scalar')->end()->end()->scalarNode('alias')->isRequired()->end()->arrayNode('options')->addDefaultsIfNotSet()->children()->scalarNode('profile')->defaultValue('2.0')->beforeNormalization()->ifTrue(function ($v) {
         return false === is_string($v);
     })->then(function ($v) {
         return sprintf('%.1f', $v);
     })->end()->end()->scalarNode('cluster')->defaultNull()->end()->end()->end()->end()->end()->end()->end();
 }
コード例 #11
0
 /**
  * @param ArrayNodeDefinition $rootNode
  */
 private function addChannelHandlers(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('loggerChannel')->children()->arrayNode('logger_channel')->canBeUnset()->useAttributeAsKey('name')->prototype('array')->fixXmlConfig('channel', 'elements')->canBeUnset()->beforeNormalization()->ifString()->then(function ($v) {
         return array('elements' => array($v));
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return is_array($v) && is_numeric(key($v));
     })->then(function ($v) {
         return array('elements' => $v);
     })->end()->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->validate()->always($this->getChannelTypeValidator())->end()->children()->scalarNode('type')->validate()->ifNotInArray(array('inclusive', 'exclusive'))->thenInvalid('The type of channels has to be inclusive or exclusive')->end()->end()->arrayNode('elements')->prototype('scalar')->end()->end()->end()->end()->end()->end()->end();
 }
コード例 #12
0
 private function addRulesSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('rule', 'rules')->children()->arrayNode('rules')->cannotBeOverwritten()->prototype('array')->children()->scalarNode('unless_role')->defaultNull()->end()->scalarNode('path')->defaultNull()->info('URL path info')->end()->arrayNode('method')->beforeNormalization()->ifString()->then(function ($v) {
         return preg_split('/\\s*,\\s*/', $v);
     })->end()->useAttributeAsKey('name')->prototype('scalar')->end()->info('HTTP method')->end()->arrayNode('ips')->beforeNormalization()->ifString()->then(function ($v) {
         return preg_split('/\\s*,\\s*/', $v);
     })->end()->useAttributeAsKey('name')->prototype('scalar')->end()->info('List of ips')->end()->arrayNode('attributes')->addDefaultsIfNotSet()->cannotBeEmpty()->treatNullLike(array())->info('Request attributes')->end()->scalarNode('domain')->defaultNull()->info('depreciated, use host instead')->end()->scalarNode('host')->defaultNull()->info('URL host name')->end()->scalarNode('controller')->defaultNull()->info('controller action name')->end()->scalarNode('reverse_proxy_ttl')->defaultNull()->end()->arrayNode('controls')->beforeNormalization()->ifString()->then(function ($v) {
         return preg_split('/\\s*,\\s*/', $v);
     })->end()->useAttributeAsKey('name')->prototype('scalar')->end()->end()->arrayNode('vary')->beforeNormalization()->ifString()->then(function ($v) {
         return preg_split('/\\s*,\\s*/', $v);
     })->end()->prototype('scalar')->end()->end()->end()->end()->end()->end();
 }
コード例 #13
0
 public function addProvidersSection(ArrayNodeDefinition $rootNode)
 {
     $providerNodeBuilder = $rootNode->fixXmlConfig('provider')->children()->arrayNode('providers')->example(array('sis' => array('base_url' => 'http://sisapi.example.com', 'http_client' => 'Guzzle', 'auth' => array('module' => 'Auth2', 'rpc_path' => '/auth/rpc', 'username' => 'service_username', 'password' => 'service_password', 'service_application' => 'service_app', 'service_url' => 'https://www.auth.stg.id.ubc.ca'), 'serializer' => 'JMS')))->isRequired()->requiresAtLeastOneElement()->useAttributeAsKey('class')->prototype('array');
     $providerNodeBuilder->children()->scalarNode('base_url')->end()->scalarNode('http_client')->defaultValue('Guzzle')->end()->scalarNode('serializer')->defaultValue('JMS')->end()->arrayNode('auth')->children()->scalarNode('module')->defaultValue('HttpBasic')->end()->scalarNode('rpc_path')->defaultValue('/auth/rpc')->end()->scalarNode('username')->isRequired()->end()->scalarNode('password')->isRequired()->end()->scalarNode('service_application')->end()->scalarNode('service_url')->defaultValue('https://www.auth.stg.id.ubc.ca')->end()->end()->validate()->ifTrue(function ($v) {
         return 'Auth2' === $v['module'] && empty($v['service_application']);
     })->thenInvalid('The service_application name has to be specified to use Auth2 module.')->end()->end()->scalarNode('path')->end()->end();
     $providerNodeBuilder->end()->validate()->ifTrue(function ($v) {
         return isset($v['sis']) && empty($v['sis']['base_url']);
     })->thenInvalid('The base_url has to specified to use sis data provider.')->end()->validate()->ifTrue(function ($v) {
         return isset($v['xml']) && empty($v['xml']['path']);
     })->thenInvalid('The base_url has to specified to use xml data provider.')->end()->end();
 }
コード例 #14
0
ファイル: Configuration.php プロジェクト: laubosslink/lab
 private function addGlobalsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('global')->children()->arrayNode('globals')->useAttributeAsKey('key')->example(array('foo' => '"@bar"', 'pi' => 3.14))->prototype('array')->beforeNormalization()->ifTrue(function ($v) {
         return is_string($v) && 0 === strpos($v, '@');
     })->then(function ($v) {
         return array('id' => substr($v, 1), 'type' => 'service');
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         if (is_array($v)) {
             $keys = array_keys($v);
             sort($keys);
             return $keys !== array('id', 'type') && $keys !== array('value');
         }
         return true;
     })->then(function ($v) {
         return array('value' => $v);
     })->end()->children()->scalarNode('id')->end()->scalarNode('type')->validate()->ifNotInArray(array('service'))->thenInvalid('The %s type is not supported')->end()->end()->variableNode('value')->end()->end()->end()->end()->end();
 }
コード例 #15
0
 private function addFilesystemSection(ArrayNodeDefinition $node)
 {
     $node
         ->fixXmlConfig('filesystem')
         ->children()
             ->arrayNode('filesystems')
                 ->useAttributeAsKey('name')
                 ->prototype('array')
                 ->children()
                     ->scalarNode('adapter')->isRequired()->end()
                     ->scalarNode('cache')->defaultNull()->end()
                     ->scalarNode('alias')->defaultNull()->end()
                     ->scalarNode('mount')->defaultNull()->end()
                 ->end()
             ->end()
         ->end()
     ;
 }
コード例 #16
0
 /**
  * Adds the snc_redis.clients configuration
  *
  * @param ArrayNodeDefinition $rootNode
  */
 private function addClientsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('client')->children()->arrayNode('clients')->isRequired()->requiresAtLeastOneElement()->useAttributeAsKey('alias', false)->prototype('array')->fixXmlConfig('dsn')->children()->scalarNode('type')->isRequired()->validate()->ifTrue(function ($v) {
         return !in_array($v, array('predis', 'phpredis'));
     })->thenInvalid('The redis client type %s is invalid.')->end()->end()->scalarNode('alias')->isRequired()->end()->booleanNode('logging')->defaultValue($this->debug)->end()->arrayNode('dsns')->isRequired()->performNoDeepMerging()->beforeNormalization()->ifString()->then(function ($v) {
         return (array) $v;
     })->end()->beforeNormalization()->always()->then(function ($v) {
         return array_map(function ($dsn) {
             $parsed = new RedisDsn($dsn);
             return $parsed->isValid() ? $parsed : $dsn;
         }, $v);
     })->end()->prototype('variable')->validate()->ifTrue(function ($v) {
         return is_string($v);
     })->thenInvalid('The redis DSN %s is invalid.')->end()->end()->end()->scalarNode('alias')->isRequired()->end()->arrayNode('options')->addDefaultsIfNotSet()->children()->booleanNode('connection_async')->defaultFalse()->end()->booleanNode('connection_persistent')->defaultFalse()->end()->scalarNode('connection_timeout')->defaultValue(5)->end()->scalarNode('read_write_timeout')->defaultNull()->end()->booleanNode('iterable_multibulk')->defaultFalse()->end()->booleanNode('throw_errors')->defaultTrue()->end()->scalarNode('profile')->defaultValue('2.4')->beforeNormalization()->ifTrue(function ($v) {
         return false === is_string($v);
     })->then(function ($v) {
         return sprintf('%.1F', $v);
     })->end()->end()->scalarNode('cluster')->defaultNull()->end()->scalarNode('prefix')->defaultNull()->end()->booleanNode('replication')->defaultFalse()->end()->end()->end()->end()->end()->end()->end();
 }
コード例 #17
0
 private function addTwigOptions(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('path')->children()->variableNode('autoescape')->defaultValue(array('Symfony\\Bundle\\TwigBundle\\TwigDefaultEscapingStrategy', 'guess'))->end()->scalarNode('autoescape_service')->defaultNull()->end()->scalarNode('autoescape_service_method')->defaultNull()->end()->scalarNode('base_template_class')->example('Twig_Template')->end()->scalarNode('cache')->defaultValue('%kernel.cache_dir%/twig')->end()->scalarNode('charset')->defaultValue('%kernel.charset%')->end()->scalarNode('debug')->defaultValue('%kernel.debug%')->end()->scalarNode('strict_variables')->end()->scalarNode('auto_reload')->end()->scalarNode('optimizations')->end()->arrayNode('paths')->normalizeKeys(false)->useAttributeAsKey('paths')->beforeNormalization()->always()->then(function ($paths) {
         $normalized = array();
         foreach ($paths as $path => $namespace) {
             if (is_array($namespace)) {
                 // xml
                 $path = $namespace['value'];
                 $namespace = $namespace['namespace'];
             }
             // path within the default namespace
             if (ctype_digit((string) $path)) {
                 $path = $namespace;
                 $namespace = null;
             }
             $normalized[$path] = $namespace;
         }
         return $normalized;
     })->end()->prototype('variable')->end()->end()->end();
 }
コード例 #18
0
 /**
  * Add service bus section to configuration tree
  *
  * @link https://github.com/prooph/service-bus
  *
  * @param string $type Bus type
  * @param ArrayNodeDefinition $node
  */
 private function addServiceBusSection(string $type, ArrayNodeDefinition $node)
 {
     $treeBuilder = new TreeBuilder();
     $routesNode = $treeBuilder->root('routes');
     /** @var $routesNode ArrayNodeDefinition */
     $handlerNode = $routesNode->requiresAtLeastOneElement()->useAttributeAsKey($type)->prototype('event' === $type ? 'array' : 'scalar');
     if ('event' === $type) {
         $handlerNode->beforeNormalization()->ifTrue(function ($v) {
             // XML uses listener nodes
             return isset($v['listener']);
         })->then(function ($v) {
             // fix single node in XML
             return (array) $v['listener'];
         })->end()->prototype('scalar')->beforeNormalization()->ifTrue(function ($v) {
             return strpos($v, '@') === 0;
         })->then(function ($v) {
             return substr($v, 1);
         })->end()->end()->end();
     } else {
         $handlerNode->beforeNormalization()->ifTrue(function ($v) {
             return strpos($v, '@') === 0;
         })->then(function ($v) {
             return substr($v, 1);
         })->end();
     }
     $node->fixXmlConfig($type . '_bus', $type . '_buses')->children()->arrayNode($type . '_buses')->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array')->fixXmlConfig('plugin', 'plugins')->children()->scalarNode('message_factory')->beforeNormalization()->ifTrue(function ($v) {
         return strpos($v, '@') === 0;
     })->then(function ($v) {
         return substr($v, 1);
     })->end()->defaultValue('prooph_service_bus.message_factory')->end()->arrayNode('plugins')->beforeNormalization()->ifString()->then(function ($v) {
         return [$v];
     })->end()->prototype('scalar')->beforeNormalization()->ifTrue(function ($v) {
         return strpos($v, '@') === 0;
     })->then(function ($v) {
         return substr($v, 1);
     })->end()->end()->end()->arrayNode('router')->fixXmlConfig('route', 'routes')->children()->scalarNode('type')->beforeNormalization()->ifTrue(function ($v) {
         return strpos($v, '@') === 0;
     })->then(function ($v) {
         return substr($v, 1);
     })->end()->defaultValue('prooph_service_bus.' . $type . '_bus_router')->end()->append($routesNode)->end()->end()->end()->end();
 }
コード例 #19
0
ファイル: Configuration.php プロジェクト: geoffreytran/zym
 /**
  * Adds the configuration for the "indexes" key
  */
 private function addIndexesSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('index')->children()->arrayNode('indexes')->useAttributeAsKey('name')->prototype('array')->performNoDeepMerging()->children()->scalarNode('client')->end()->end()->end()->end()->end();
 }
コード例 #20
0
 private function addEncodersSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('encoder')->children()->arrayNode('encoders')->example(array('Acme\\DemoBundle\\Entity\\User1' => 'sha512', 'Acme\\DemoBundle\\Entity\\User2' => array('algorithm' => 'sha512', 'encode_as_base64' => 'true', 'iterations' => 5000)))->requiresAtLeastOneElement()->useAttributeAsKey('class')->prototype('array')->canBeUnset()->performNoDeepMerging()->beforeNormalization()->ifString()->then(function ($v) {
         return array('algorithm' => $v);
     })->end()->children()->scalarNode('algorithm')->cannotBeEmpty()->end()->scalarNode('hash_algorithm')->info('Name of hashing algorithm for PBKDF2 (i.e. sha256, sha512, etc..) See hash_algos() for a list of supported algorithms.')->defaultValue('sha512')->end()->scalarNode('key_length')->defaultValue(40)->end()->booleanNode('ignore_case')->defaultFalse()->end()->booleanNode('encode_as_base64')->defaultTrue()->end()->scalarNode('iterations')->defaultValue(5000)->end()->integerNode('cost')->min(4)->max(31)->defaultValue(13)->end()->scalarNode('id')->end()->end()->end()->end()->end();
 }
コード例 #21
0
ファイル: MainConfiguration.php プロジェクト: rfc1483/blog
 private function addEncodersSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('encoder')->children()->arrayNode('encoders')->requiresAtLeastOneElement()->useAttributeAsKey('class')->prototype('array')->canBeUnset()->performNoDeepMerging()->beforeNormalization()->ifString()->then(function ($v) {
         return array('algorithm' => $v);
     })->end()->children()->scalarNode('algorithm')->cannotBeEmpty()->end()->booleanNode('ignore_case')->defaultFalse()->end()->booleanNode('encode_as_base64')->defaultTrue()->end()->scalarNode('iterations')->defaultValue(5000)->end()->scalarNode('id')->end()->end()->end()->end()->end();
 }
コード例 #22
0
ファイル: Configuration.php プロジェクト: rodchyn/AMFBundle
 private function addMappingsSection(ArrayNodeDefinition $node)
 {
     $node->fixXmlConfig('mapping')->children()->arrayNode('mappings')->useAttributeAsKey('alias')->prototype('array')->performNoDeepMerging()->beforeNormalization()->ifString()->then(function ($v) {
         return array('class' => $v);
     })->end()->children()->scalarNode('class')->cannotBeEmpty()->end()->end()->end()->end()->end();
 }
コード例 #23
0
 /**
  * Adds the "resolve_target_documents" config section.
  *
  * @param ArrayNodeDefinition $rootNode
  */
 private function addResolveTargetDocumentsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('resolve_target_document')->children()->arrayNode('resolve_target_documents')->useAttributeAsKey('interface')->prototype('scalar')->cannotBeEmpty()->end()->end()->end();
 }
コード例 #24
0
 private function addResourceOwnersConfiguration(ArrayNodeDefinition $node)
 {
     $node->fixXmlConfig('resource_owner')->children()->arrayNode('resource_owners')->isRequired()->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('base_url')->end()->scalarNode('access_token_url')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('authorization_url')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('request_token_url')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('revoke_token_url')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('infos_url')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('client_id')->cannotBeEmpty()->end()->scalarNode('client_secret')->cannotBeEmpty()->end()->scalarNode('realm')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('scope')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('user_response_class')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('service')->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->scalarNode('type')->validate()->ifTrue(function ($type) {
         return !Configuration::isResourceOwnerSupported($type);
     })->thenInvalid('Unknown resource owner type "%s".')->end()->validate()->ifTrue(function ($v) {
         return empty($v);
     })->thenUnset()->end()->end()->arrayNode('paths')->useAttributeAsKey('name')->prototype('variable')->validate()->ifTrue(function ($v) {
         if (null === $v) {
             return true;
         }
         if (is_array($v)) {
             return 0 === count($v);
         }
         if (is_string($v)) {
             return empty($v);
         }
         return !is_numeric($v);
     })->thenInvalid('Path can be only string or array type.')->end()->end()->end()->arrayNode('options')->useAttributeAsKey('name')->prototype('scalar')->end()->end()->end()->validate()->ifTrue(function ($c) {
         // skip if this contains a service
         if (isset($c['service'])) {
             return false;
         }
         // for each type at least these have to be set
         foreach (array('type', 'client_id', 'client_secret') as $child) {
             if (!isset($c[$child])) {
                 return true;
             }
         }
         return false;
     })->thenInvalid("You should set at least the 'type', 'client_id' and the 'client_secret' of a resource owner.")->end()->validate()->ifTrue(function ($c) {
         // skip if this contains a service
         if (isset($c['service'])) {
             return false;
         }
         // Only validate the 'oauth2' and 'oauth1' type
         if ('oauth2' !== $c['type'] && 'oauth1' !== $c['type']) {
             return false;
         }
         $children = array('authorization_url', 'access_token_url', 'request_token_url', 'infos_url');
         foreach ($children as $child) {
             // This option exists only for OAuth1.0a
             if ('request_token_url' === $child && 'oauth2' === $c['type']) {
                 continue;
             }
             if (!isset($c[$child])) {
                 return true;
             }
         }
         return false;
     })->thenInvalid("All parameters are mandatory for types 'oauth2' and 'oauth1'. Check if you're missing one of: 'access_token_url', 'authorization_url', 'infos_url' and 'request_token_url' for 'oauth1'.")->end()->validate()->ifTrue(function ($c) {
         // skip if this contains a service
         if (isset($c['service'])) {
             return false;
         }
         // Only validate the 'oauth2' and 'oauth1' type
         if ('oauth2' !== $c['type'] && 'oauth1' !== $c['type']) {
             return false;
         }
         // one of this two options must be set
         if (0 === count($c['paths'])) {
             return !isset($c['user_response_class']);
         }
         foreach (array('identifier', 'nickname', 'realname') as $child) {
             if (!isset($c['paths'][$child])) {
                 return true;
             }
         }
         return false;
     })->thenInvalid("At least the 'identifier', 'nickname' and 'realname' paths should be configured for 'oauth2' and 'oauth1' types.")->end()->validate()->ifTrue(function ($c) {
         if (isset($c['service'])) {
             // ignore paths & options if none were set
             return 0 !== count($c['paths']) || 0 !== count($c['options']) || 3 < count($c);
         }
         return false;
     })->thenInvalid("If you're setting a 'service', no other arguments should be set.")->end()->end()->end()->end();
 }
コード例 #25
0
 /**
  * Adds the configuration for the "connections" key
  */
 private function addConnectionsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('connection')->children()->arrayNode('connections')->useAttributeAsKey('id')->prototype('array')->performNoDeepMerging()->children()->scalarNode('server')->defaultNull()->end()->end()->append($this->addConnectionOptionsNode())->end()->end()->end();
 }
コード例 #26
0
ファイル: Configuration.php プロジェクト: seydu/MediaBundle
 private function addImageSection(ArrayNodeDefinition $node)
 {
     $node->fixXmlConfig('extra_filter')->children()->enumNode('use_imagine')->values(array(true, false, 'auto'))->defaultValue('auto')->end()->arrayNode('imagine_filters')->addDefaultsIfNotSet()->children()->scalarNode('upload_thumbnail')->defaultValue('image_upload_thumbnail')->end()->scalarNode('elfinder_thumbnail')->defaultValue('elfinder_thumbnail')->end()->end()->end()->arrayNode('extra_filters')->prototype('scalar')->end()->end()->end();
     return $node;
 }
コード例 #27
0
 /**
  * Adds the configuration for the "indexes" key
  */
 private function addIndexesSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('index')->children()->arrayNode('indexes')->useAttributeAsKey('name')->prototype('array')->children()->scalarNode('index_name')->info('Defaults to the name of the index, but can be modified if the index name is different in ElasticSearch')->end()->booleanNode('use_alias')->defaultValue(false)->end()->scalarNode('client')->end()->scalarNode('finder')->treatNullLike(true)->defaultFalse()->end()->arrayNode('type_prototype')->children()->scalarNode('index_analyzer')->end()->scalarNode('search_analyzer')->end()->append($this->getPersistenceNode())->append($this->getSerializerNode())->end()->end()->variableNode('settings')->defaultValue(array())->end()->end()->append($this->getTypesNode())->end()->end()->end();
 }
コード例 #28
0
 private function addFiltersSection(ArrayNodeDefinition $rootNode, ExecutableFinder $finder)
 {
     $rootNode->fixXmlConfig('filter')->children()->arrayNode('filters')->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('variable')->treatNullLike(array())->validate()->ifTrue(function ($v) {
         return !is_array($v);
     })->thenInvalid('The assetic.filters config %s must be either null or an array.')->end()->end()->validate()->always(function ($v) use($finder) {
         if (isset($v['compass']) && !isset($v['compass']['bin'])) {
             $v['compass']['bin'] = $finder->find('compass', '/usr/bin/compass');
         }
         return $v;
     })->end()->end()->end();
 }
コード例 #29
0
 /**
  * Add commands configuration
  *
  * @param ArrayNodeDefinition $node
  */
 protected function addCommands(ArrayNodeDefinition $node)
 {
     $node->fixXmlConfig('command')->children()->arrayNode('commands')->addDefaultsIfNotSet()->children()->scalarNode('rabbitmq_consumer')->defaultValue('rabbitmq:consumer -m %%1$d %%2$s')->end()->scalarNode('rabbitmq_multiple_consumer')->defaultValue('rabbitmq:multiple-consumer -m %%1$d %%2$s')->end()->end()->end()->end();
 }
コード例 #30
0
ファイル: Configuration.php プロジェクト: 3116246/haolinju
 /**
  * Adds the configuration for the "connections" key
  */
 private function addConnectionsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->fixXmlConfig('connection')->children()->arrayNode('connections')->useAttributeAsKey('id')->prototype('array')->performNoDeepMerging()->children()->scalarNode('server')->defaultNull()->end()->arrayNode('options')->performNoDeepMerging()->addDefaultsIfNotSet()->children()->booleanNode('connect')->end()->scalarNode('persist')->end()->scalarNode('timeout')->end()->booleanNode('replicaSet')->end()->scalarNode('username')->end()->scalarNode('password')->end()->end()->end()->end()->end()->end()->end();
 }