コード例 #1
0
 public function addConfiguration(ArrayNodeDefinition $rootNode)
 {
     $dsnParser = $this->dsnParser;
     $rootNode->beforeNormalization()->always(function ($config) use($dsnParser) {
         if (isset($config['dsn'])) {
             $config = array_merge($config, $dsnParser->parse($config['dsn']));
         }
         if (isset($config[Client::REQUEST_OPTIONS])) {
             $config['request']['options'] = $config[Client::REQUEST_OPTIONS];
             unset($config[Client::REQUEST_OPTIONS]);
         }
         if (isset($config[Client::CURL_OPTIONS])) {
             $config['curl']['options'] = $config[Client::CURL_OPTIONS];
             unset($config[Client::CURL_OPTIONS]);
         }
         if (isset($config[Client::COMMAND_PARAMS])) {
             $config['command']['params'] = $config[Client::COMMAND_PARAMS];
             unset($config[Client::COMMAND_PARAMS]);
         }
         return $config;
     })->end()->children()->scalarNode('public_key')->isRequired()->end()->scalarNode('secret_key')->isRequired()->end()->scalarNode('project_id')->isRequired()->end()->enumNode('protocol')->defaultValue('https')->values(array('http', 'https'))->end()->scalarNode('host')->defaultValue('app.getsentry.com')->end()->scalarNode('path')->defaultValue('/')->end()->scalarNode('port')->defaultNull()->end()->scalarNode('dsn')->end()->variableNode('exception_factory')->end()->arrayNode('request')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->arrayNode('curl')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->arrayNode('command')->addDefaultsIfNotSet()->children()->arrayNode('params')->addDefaultsIfNotSet()->children()->scalarNode('level')->end()->scalarNode('logger')->end()->scalarNode('platform')->end()->arrayNode('tags')->prototype('scalar')->end()->end()->arrayNode('extra')->prototype('scalar')->end()->end()->scalarNode('server_name')->defaultValue(gethostname())->end()->end()->end()->end()->end()->arrayNode('ignored_exceptions')->beforeNormalization()->always(function (array $ignoredExceptions) {
         $newIgnoredExceptions = array();
         foreach ($ignoredExceptions as $class => $ignored) {
             if (!is_bool($ignored)) {
                 $class = $ignored;
                 $ignored = true;
             }
             $newIgnoredExceptions[$class] = $ignored;
         }
         return $newIgnoredExceptions;
     })->end()->prototype('scalar')->end()->end()->end();
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('array')->beforeNormalization()->ifString()->then(function ($v) {
         return ['pattern' => $v];
     })->end()->children()->scalarNode('pattern')->isRequired()->end()->arrayNode('ignore')->beforeNormalization()->ifNull()->thenEmptyArray()->ifString()->then(function ($v) {
         return array($v);
     })->end()->prototype('scalar')->end()->end()->arrayNode('options')->beforeNormalization()->ifNull()->thenEmptyArray()->end()->prototype('variable')->end()->end()->end()->end();
 }
コード例 #3
0
 private function getAllowHeaders()
 {
     $node = new ArrayNodeDefinition('allow_headers');
     $node->beforeNormalization()->always(function ($v) {
         if ($v === '*') {
             return array('*');
         }
         return $v;
     })->end()->prototype('scalar')->end();
     return $node;
 }
コード例 #4
0
 private function addDeprecationsSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['list_max_results']);
     })->then(function ($v) {
         if (!isset($v['list'])) {
             $v['list'] = array();
         }
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['list']['max_results'])) {
             $v['list']['max_results'] = $v['list_max_results'];
         }
         unset($v['list_max_results']);
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['list_actions']);
     })->then(function ($v) {
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['list']['actions'])) {
             $v['list']['actions'] = $v['list_actions'];
         }
         unset($v['list_actions']);
         return $v;
     })->end()->beforeNormalization()->always()->then(function ($v) {
         if (!isset($v['design'])) {
             $v['design'] = array('assets' => array());
         }
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['assets']['css']);
     })->then(function ($v) {
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['design']['assets']['css'])) {
             $v['design']['assets']['css'] = $v['assets']['css'];
         }
         unset($v['assets']['css']);
         return $v;
     })->end()->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['assets']['js']);
     })->then(function ($v) {
         // if the new option is defined, don't override it with the legacy option
         if (!isset($v['design']['assets']['js'])) {
             $v['design']['assets']['js'] = $v['assets']['js'];
         }
         unset($v['assets']['js']);
         return $v;
     })->end()->beforeNormalization()->always()->then(function ($v) {
         if (isset($v['assets'])) {
             unset($v['assets']);
         }
         return $v;
     })->end()->children()->variableNode('list_actions')->info('DEPRECATED: use the "actions" option of the "list" view.')->end()->integerNode('list_max_results')->info('DEPRECATED: use "max_results" option under the "list" global key.')->end()->arrayNode('assets')->performNoDeepMerging()->children()->arrayNode('css')->info('DEPRECATED: use the "design -> assets -> css" option.')->end()->arrayNode('js')->info('DEPRECATED: use the "design -> assets -> js" option.')->end()->end()->end()->end();
 }
コード例 #5
0
 /**
  * Setups configuration for the extension.
  *
  * @param ArrayNodeDefinition $builder
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $default_fixtures = array('admin_user' => '\\Behat\\MageExtension\\Fixture\\AdminUserFixtureFactory', 'cart_product' => '\\Behat\\MageExtension\\Fixture\\CartProductFixtureFactory', 'customer' => '\\Behat\\MageExtension\\Fixture\\CustomerFixtureFactory', 'product' => '\\Behat\\MageExtension\\Fixture\\ProductFixtureFactory', 'configurable_product' => '\\Behat\\MageExtension\\Fixture\\ConfigurableProductFixtureFactory', 'attribute_set' => '\\Behat\\MageExtension\\Fixture\\AttributeSetFixtureFactory', 'attribute' => '\\Behat\\MageExtension\\Fixture\\AttributeFixtureFactory', 'attribute_with_options' => '\\Behat\\MageExtension\\Fixture\\AttributeWithOptionsFixtureFactory');
     $builder->beforeNormalization()->always()->then(function ($v) use($default_fixtures) {
         if (array_key_exists('fixture_factories', $v) && is_array($v['fixture_factories'])) {
             $v['fixture_factories'] = array_merge($default_fixtures, $v['fixture_factories']);
         } else {
             $v['fixture_factories'] = $default_fixtures;
         }
         return $v;
     })->end()->addDefaultsIfNotSet()->children()->scalarNode('default_page_class')->defaultValue('\\Behat\\MageExtension\\Page\\MagePage')->end()->scalarNode('category_page_class')->defaultValue('\\Behat\\MageExtension\\Page\\Category')->end()->scalarNode('product_page_class')->defaultValue('\\Behat\\MageExtension\\Page\\Product')->end()->arrayNode('custom_page_classes')->prototype('scalar')->end()->end()->arrayNode('fixture_factories')->prototype('scalar');
 }
コード例 #6
0
ファイル: Configuration.php プロジェクト: RuntyCybin/csymfony
 private function addFormSection(ArrayNodeDefinition $rootNode)
 {
     $rootNode->beforeNormalization()->ifTrue(function ($v) {
         return isset($v['form']['resources']);
     })->then(function ($v) {
         trigger_error('The twig.form.resources configuration key is deprecated since version 2.6 and will be removed in 3.0. Use the twig.form_themes configuration key instead.', E_USER_DEPRECATED);
         return $v;
     })->end()->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 version 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();
 }
コード例 #7
0
 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifString()->then(function ($v) {
         $home = getenv('HOME');
         $filepath = $home . '/.openl10n/server.conf';
         $data = array();
         if (file_exists($filepath)) {
             $data = parse_ini_file($filepath, true);
         }
         if (isset($data[$v])) {
             return $data[$v];
         }
         return array('hostname' => $v);
     })->end()->children()->scalarNode('hostname')->isRequired()->cannotBeEmpty()->end()->scalarNode('username')->isRequired()->cannotBeEmpty()->end()->scalarNode('password')->isRequired()->cannotBeEmpty()->end()->booleanNode('use_ssl')->beforeNormalization()->ifString()->then(function ($v) {
         return (bool) $v;
     })->end()->defaultFalse()->end()->integerNode('port')->defaultNull()->end()->end();
 }
コード例 #8
0
 public function addConfiguration(ArrayNodeDefinition $rootNode)
 {
     $rootNode->beforeNormalization()->always(function ($config) {
         if (isset($config[OktaClient::REQUEST_OPTIONS])) {
             $config['request']['options'] = $config[OktaClient::REQUEST_OPTIONS];
             unset($config[OktaClient::REQUEST_OPTIONS]);
         }
         if (isset($config[OktaClient::CURL_OPTIONS])) {
             $config['curl']['options'] = $config[OktaClient::CURL_OPTIONS];
             unset($config[OktaClient::CURL_OPTIONS]);
         }
         if (isset($config[OktaClient::COMMAND_PARAMS])) {
             $config['command']['params'] = $config[OktaClient::COMMAND_PARAMS];
             unset($config[OktaClient::COMMAND_PARAMS]);
         }
         return $config;
     })->end()->children()->scalarNode('api_key')->isRequired()->end()->scalarNode('host')->isRequired()->info('org.okta.com')->end()->enumNode('protocol')->defaultValue('https')->values(['http', 'https'])->end()->arrayNode('request')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->arrayNode('curl')->children()->arrayNode('options')->prototype('variable')->end()->end()->end()->end()->end();
 }
コード例 #9
0
 private function getSitemapHelperNode($type, $default)
 {
     $node = new ArrayNodeDefinition($type);
     $node->beforeNormalization()->ifTrue(function ($config) {
         return is_string($config);
     })->then(function ($config) {
         return array($config);
     })->end()->defaultValue($default)->prototype('scalar')->end()->end();
     return $node;
 }
コード例 #10
0
 /**
  * @param ArrayNodeDefinition $node
  * @param bool                $includeDlx
  * @param bool                $includeDelay
  */
 private function addExchangeSection(ArrayNodeDefinition $node, $includeDlx = true, $includeDelay = true)
 {
     $node->addDefaultsIfNotSet();
     $node->beforeNormalization()->ifString()->then(function ($value) {
         return ['type' => $value];
     });
     $exchange = $node->children();
     $exchange->scalarNode('name')->defaultNull()->info('The name to create the exchange with in the AMQP broker');
     $exchange->enumNode('type')->values([Exchg::TYPE_DIRECT, Exchg::TYPE_FANOUT, Exchg::TYPE_TOPIC, Exchg::TYPE_HEADERS])->defaultValue(Exchg::TYPE_DIRECT)->info('The exchange type');
     $exchange->booleanNode('auto_declare')->info('Whether to automatically declare the exchange on cache warmup. Only enable this when you have configure access to the exchange');
     $exchange->scalarNode('connection')->defaultNull();
     $exchange->booleanNode('durable')->defaultTrue();
     $exchange->booleanNode('passive')->defaultFalse();
     $exchange->booleanNode('auto_delete')->defaultFalse();
     $exchange->booleanNode('internal')->defaultFalse();
     $exchange->booleanNode('nowait')->defaultFalse();
     $exchange->arrayNode('arguments')->normalizeKeys(false)->prototype('scalar')->defaultValue([]);
     if ($includeDelay) {
         $exchange->booleanNode('delay')->defaultTrue()->info('Whether to enable delayed messages for this exchange');
     }
     if ($includeDlx) {
         $dlx = $exchange->arrayNode('dlx');
         $dlx->info('Create a dead letter exchange for this exchange');
         $dlx->canBeDisabled();
         // copy the entire exchange configuration here
         $this->addExchangeSection($dlx, false, false);
         $queue = $dlx->children()->arrayNode('queue');
         $this->addQueueSection($queue);
     }
 }
コード例 #11
0
 /**
  * {@inheritDoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     // Rewrite keys to define a shortcut way without allowing conflicts with real keys
     $renamedKeys = array_diff(array_keys($this->driverFactories), array('mink_loader', 'base_url', 'files_path', 'show_auto', 'show_cmd', 'show_tmp_dir', 'default_session', 'javascript_session', 'browser_name', 'sessions'));
     $builder->beforeNormalization()->always()->then(function ($v) use($renamedKeys) {
         foreach ($renamedKeys as $driverType) {
             if (!array_key_exists($driverType, $v) || isset($v['sessions'][$driverType])) {
                 continue;
             }
             $v['sessions'][$driverType][$driverType] = $v[$driverType];
             unset($v[$driverType]);
         }
         return $v;
     })->end()->addDefaultsIfNotSet()->children()->scalarNode('mink_loader')->defaultNull()->end()->scalarNode('base_url')->defaultNull()->end()->scalarNode('files_path')->defaultNull()->end()->booleanNode('show_auto')->defaultFalse()->end()->scalarNode('show_cmd')->defaultNull()->end()->scalarNode('show_tmp_dir')->defaultValue(sys_get_temp_dir())->end()->scalarNode('default_session')->defaultNull()->info('Defaults to the first non-javascript session if any, or the first session otherwise')->end()->scalarNode('javascript_session')->defaultNull()->info('Defaults to the first javascript session if any')->end()->scalarNode('browser_name')->defaultValue('firefox')->end()->end()->end();
     /** @var ArrayNodeDefinition $sessionsBuilder */
     $sessionsBuilder = $builder->children()->arrayNode('sessions')->isRequired()->requiresAtLeastOneElement()->useAttributeAsKey('name')->prototype('array');
     foreach ($this->driverFactories as $factory) {
         $factoryNode = $sessionsBuilder->children()->arrayNode($factory->getDriverName())->canBeUnset();
         $factory->configure($factoryNode);
     }
     $sessionsBuilder->validate()->ifTrue(function ($v) {
         return count($v) > 1;
     })->thenInvalid('You cannot set multiple driver types for the same session')->end()->validate()->ifTrue(function ($v) {
         return count($v) === 0;
     })->thenInvalid('You must set a driver definition for the session.')->end();
 }
コード例 #12
0
 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifNull()->thenEmptyArray()->end()->prototype('scalar')->end();
 }
コード例 #13
0
 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->ifString()->then(function ($v) {
         return array('slug' => $v);
     })->end()->children()->scalarNode('slug')->isRequired()->cannotBeEmpty()->end()->end();
 }
コード例 #14
0
 /**
  * Adds the normalization section.
  *
  * @param \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition $node The root node.
  */
 protected function addNormalizationSection(ArrayNodeDefinition $node)
 {
     $node->beforeNormalization()->always(function ($value) {
         if (!isset($value['geocoder']) && !isset($value['geocoder_request'])) {
             $value['geocoder'] = array('enabled' => false);
         }
         if (!isset($value['directions']) && !isset($value['directions_request'])) {
             $value['directions'] = array('enabled' => false);
         }
         if (!isset($value['distance_matrix']) && !isset($value['distance_matrix_request'])) {
             $value['distance_matrix'] = array('enabled' => false);
         }
         return $value;
     })->end();
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function configure(ArrayNodeDefinition $builder)
 {
     $builder->beforeNormalization()->ifString()->then(function ($path) {
         return array('' => $path);
     })->end()->defaultValue($this->defaultPaths)->treatTrueLike($this->defaultPaths)->treatNullLike(array())->treatFalseLike(array())->prototype('scalar')->end();
 }