/**
  * Loads the product configuration.
  *
  * @param array            $configs   An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $bundles = $container->getParameter('kernel.bundles');
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('block.xml');
     $loader->load('product.xml');
     $loader->load('orm.xml');
     $loader->load('form.xml');
     $loader->load('twig.xml');
     $loader->load('menu.xml');
     if (isset($bundles['FOSRestBundle']) && isset($bundles['NelmioApiDocBundle'])) {
         $loader->load('api_controllers.xml');
         $loader->load('api_form.xml');
         $loader->load('serializer.xml');
     }
     if (isset($bundles['SonataAdminBundle'])) {
         $loader->load('admin.xml');
     }
     $pool = $container->getDefinition('sonata.product.pool');
     // this value is altered by the AddProductProviderPass class
     $pool->addMethodCall('__hack', $config['products']);
     $this->registerParameters($container, $config);
     $this->registerDoctrineMapping($config);
     $this->registerSeoParameters($container, $config);
 }
Example #2
0
 /**
  * @dataProvider getDebugModes
  */
 public function testConfigTree($options, $results)
 {
     $processor = new Processor();
     $configuration = new Configuration(array());
     $config = $processor->processConfiguration($configuration, array($options));
     $this->assertEquals($results, $config);
 }
 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/'));
     $loader->load('services.yml');
     $loader->load('owners.yml');
     $processor = new Processor();
     $config = $processor->processConfiguration(new Configuration(), $configs);
     $container->getDefinition('glory_oauth.oauth_manager')->addMethodCall('setOAuthClass', array($config['oauth_class']));
     // setup http client settings
     $httpClient = $container->getDefinition('glory_oauth.http_client');
     $httpClient->addMethodCall('setVerifyPeer', array($config['http_client']['verify_peer']));
     $httpClient->addMethodCall('setTimeout', array($config['http_client']['timeout']));
     $httpClient->addMethodCall('setMaxRedirects', array($config['http_client']['max_redirects']));
     $httpClient->addMethodCall('setIgnoreErrors', array($config['http_client']['ignore_errors']));
     if (isset($config['http_client']['proxy']) && $config['http_client']['proxy'] != '') {
         $httpClient->addMethodCall('setProxy', array($config['http_client']['proxy']));
     }
     // setup services for all configured resource owners
     foreach ($config['owners'] as $name => $options) {
         $this->createOwnerService($container, $name, $options);
     }
     // check of the connect controllers etc should be enabled
     $container->setParameter('glory_oauth.auto_register', $config['auto_register']);
     $container->setAlias('glory_oauth.connect', $config['connect']);
 }
Example #4
0
 function __construct($configFile)
 {
     $yaml = new Parser();
     $config = $yaml->parse(file_get_contents($configFile));
     $processor = new Processor();
     $this->config = $processor->processConfiguration(new Schema(), $config);
 }
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $config = $processor->processConfiguration(new Configuration(), $configs);
     $loader = new XmlFileLoader($container, new FileLocator(array(__DIR__ . '/../Resources/config')));
     $loader->load('services.xml');
     $container->setParameter('jms_i18n_routing.default_locale', $config['default_locale']);
     $container->setParameter('jms_i18n_routing.locales', $config['locales']);
     $container->setParameter('jms_i18n_routing.catalogue', $config['catalogue']);
     $container->setParameter('jms_i18n_routing.strategy', $config['strategy']);
     $this->addClassesToCompile(array($container->getDefinition('jms_i18n_routing.router')->getClass()));
     if ('prefix' === $config['strategy']) {
         $container->getDefinition('jms_i18n_routing.locale_choosing_listener')->setPublic(true)->addTag('kernel.event_listener', array('event' => 'kernel.exception', 'priority' => 128));
     }
     if ($config['hosts']) {
         $container->getDefinition('jms_i18n_routing.router')->addMethodCall('setHostMap', array($config['hosts']));
         $container->getDefinition('jms_i18n_routing.locale_changing_listener')->setPublic(true)->addTag('kernel.event_listener', array('event' => 'kernel.request', 'priority' => 120))->addArgument(array_flip($config['hosts']));
         $this->addClassesToCompile(array($container->getDefinition('jms_i18n_routing.locale_changing_listener')->getClass()));
     }
     // remove route extractor if JMSTranslationBundle is not enabled to avoid any problems
     $bundles = $container->getParameter('kernel.bundles');
     if (!isset($bundles['JMSTranslationBundle'])) {
         $container->removeDefinition('jms_i18n_routing.route_translation_extractor');
     }
 }
Example #6
0
 /**
  * @param array $phphookerConfig
  * @param array $expectedConfig
  *
  * @dataProvider configurationProvider
  */
 public function testProcessConfiguration(array $phphookerConfig, array $expectedConfig)
 {
     $configuration = new Configuration();
     $processor = new Processor();
     $returnedConfig = $processor->processConfiguration($configuration, ['phphooker' => $phphookerConfig]);
     $this->assertEquals($expectedConfig, $returnedConfig);
 }
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     // first assemble the adapter factories
     $factoriesConfig = new FactoriesConfiguration();
     $config = $processor->processConfiguration($factoriesConfig, $configs);
     $factories = $this->createProviderFactories($config, $container);
     // then handle to main configuration part
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     // then check the providers configuration
     $providersConfig = new ProvidersConfiguration($config['providers'], $factories);
     $providersConfig = $this->processConfiguration($providersConfig, $configs);
     // and now, create the providers required by the configuration
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $loader->load('providers.xml');
     // start fixing providers definitions
     $definition = $container->getDefinition('sms.sender');
     foreach ($config['providers'] as $provider) {
         $id = $this->createProvider($provider, $factories, $container, $providersConfig);
         // also register it to the main sms.sender service
         $definition->addMethodCall('registerProvider', array(new Reference($id)));
     }
     // fix the sms.http_adapter definition to point to the right adapter
     $container->setAlias('sms.http_adapter', sprintf('sms.http_adapter.%s', $config['http_adapter']));
     $container->getAlias('sms.http_adapter')->setPublic(false);
     // define an alias to the real pooling service (will be used by the compiler pass)
     if ($config['pool'] !== null) {
         $container->setAlias('sms.pool', sprintf('sms.pool.%s', $config['pool']));
     }
 }
 public function __construct(ContainerInterface $container, array $config)
 {
     $this->container = $container;
     $processor = new Processor();
     $configuration = new MappedContainerHandlerProviderConfiguration();
     $this->config = $processor->processConfiguration($configuration, [$config]);
 }
 /**
  * Responds to the "white_october_admin" configuration parameter.
  *
  * @param array            $configs
  * @param ContainerBuilder $container
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('admin.xml');
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->process($configuration->getConfigTree(), $configs);
     // data managers
     if (!empty($config['data_managers']['mandango'])) {
         $loader->load('data_manager_mandango.xml');
     }
     if (!empty($config['data_managers']['doctrine']['orm'])) {
         $loader->load('data_manager_doctrine_orm.xml');
     }
     if (!empty($config['data_managers']['doctrine']['odm'])) {
         $loader->load('data_manager_doctrine_odm.xml');
     }
     // admins
     $adminIds = array();
     foreach ($config['admins'] as $admin) {
         $definition = new Definition($admin['class']);
         $definition->addMethodCall('setContainer', array(new Reference('service_container')));
         $classId = str_replace('\\', '_', $admin['class']);
         $adminId = 'white_october_admin.admin.' . $classId;
         $container->setDefinition($adminId, $definition);
         $adminIds[] = $adminId;
     }
     $container->getDefinition('white_october_admin.admin_factory')->replaceArgument(0, $adminIds);
 }
Example #10
0
 public function testExtensions()
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, [['extensions' => [['route' => 'test_route', 'label' => 'Foo Extension', 'icon' => 'bar']]]]);
     $this->assertEquals([['route' => 'test_route', 'label' => 'Foo Extension', 'role' => 'ROLE_ADMIN', 'icon' => 'bar']], $config['extensions']);
 }
 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $processor = new Processor();
     $configuration = new Configuration();
     // merges the configs 1 array key into 0 array key - 1 is from the dev settings
     if (isset($configs[1])) {
         $configs = array(0 => array_merge($configs[0], $configs[1]));
     }
     if (isset($configs[0]['formatting'])) {
         $configs[0]['compilerFlags'][] = sprintf("--formatting=%s", $configs[0]['formatting']);
         unset($configs[0]['formatting']);
     }
     if (isset($configs[0]['debug'])) {
         $configs[0]['compilerFlags'][] = sprintf("--define='goog.DEBUG=%s'", $configs[0]['debug'] === TRUE ? 'true' : 'false');
         unset($configs[0]['debug']);
     } else {
         $configs[0]['compilerFlags'][] = sprintf("--define='goog.DEBUG=%s'", 'false');
     }
     if (isset($configs[0]['debugOutput'])) {
         $configs[0]['compilerFlags'][] = sprintf("--debug=%s", $configs[0]['debugOutput'] === TRUE ? 'true' : 'false');
         unset($configs[0]['debugOutput']);
     } else {
         $configs[0]['compilerFlags'][] = sprintf("--debug=%s", 'false');
     }
     $config = $processor->processConfiguration($configuration, $configs);
     $container->setParameter('platinum_pixs_google_closure_library.outputMode', $config['outputMode']);
     $container->setParameter('platinum_pixs_google_closure_library.compilerFlags', $config['compilerFlags']);
     $container->setParameter('platinum_pixs_google_closure_library.externs', $config['externs']);
     $container->setParameter('platinum_pixs_google_closure_library.root', $config['root']);
 }
 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $container->setParameter('nelmio_api_doc.motd.template', $config['motd']['template']);
     $container->setParameter('nelmio_api_doc.exclude_sections', $config['exclude_sections']);
     $container->setParameter('nelmio_api_doc.api_name', $config['name']);
     $container->setParameter('nelmio_api_doc.sandbox.enabled', $config['sandbox']['enabled']);
     $container->setParameter('nelmio_api_doc.sandbox.endpoint', $config['sandbox']['endpoint']);
     $container->setParameter('nelmio_api_doc.sandbox.accept_type', $config['sandbox']['accept_type']);
     $container->setParameter('nelmio_api_doc.sandbox.body_format.formats', $config['sandbox']['body_format']['formats']);
     $container->setParameter('nelmio_api_doc.sandbox.body_format.default_format', $config['sandbox']['body_format']['default_format']);
     $container->setParameter('nelmio_api_doc.sandbox.request_format.method', $config['sandbox']['request_format']['method']);
     $container->setParameter('nelmio_api_doc.sandbox.request_format.default_format', $config['sandbox']['request_format']['default_format']);
     $container->setParameter('nelmio_api_doc.sandbox.request_format.formats', $config['sandbox']['request_format']['formats']);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('formatters.xml');
     $loader->load('services.xml');
     if ($config['request_listener']['enabled']) {
         $container->setParameter('nelmio_api_doc.request_listener.parameter', $config['request_listener']['parameter']);
         $loader->load('request_listener.xml');
     }
     if (isset($config['sandbox']['authentication'])) {
         $container->setParameter('nelmio_api_doc.sandbox.authentication', $config['sandbox']['authentication']);
     }
     // backwards compatibility for Symfony2.1 https://github.com/nelmio/NelmioApiDocBundle/issues/231
     if (!interface_exists('\\Symfony\\Component\\Validator\\MetadataFactoryInterface')) {
         $container->setParameter('nelmio_api_doc.parser.validation_parser.class', 'Nelmio\\ApiDocBundle\\Parser\\ValidationParserLegacy');
     }
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $output = new SymfonyStyle($input, $output);
     if (false !== strpos($input->getFirstArgument(), ':d')) {
         $output->caution('The use of "config:debug" command is deprecated since version 2.7 and will be removed in 3.0. Use the "debug:config" instead.');
     }
     $name = $input->getArgument('name');
     if (empty($name)) {
         $output->comment('Provide the name of a bundle as the first argument of this command to dump its configuration.');
         $output->newLine();
         $this->listBundles($output);
         return;
     }
     $extension = $this->findExtension($name);
     $container = $this->compileContainer();
     $configs = $container->getExtensionConfig($extension->getAlias());
     $configuration = $extension->getConfiguration($configs, $container);
     $this->validateConfiguration($extension, $configuration);
     $configs = $container->getParameterBag()->resolveValue($configs);
     $processor = new Processor();
     $config = $processor->processConfiguration($configuration, $configs);
     if ($name === $extension->getAlias()) {
         $output->title(sprintf('Current configuration for extension with alias "%s"', $name));
     } else {
         $output->title(sprintf('Current configuration for "%s"', $name));
     }
     $output->writeln(Yaml::dump(array($extension->getAlias() => $config), 3));
 }
 /**
  * Loads the url shortener configuration.
  *
  * @param array            $configs   An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('block.xml');
     $loader->load('form.xml');
     $loader->load('core.xml');
     $loader->load('exception.xml');
     $this->configureContext($container, $config);
     $this->configureLoaderChain($container, $config);
     $this->configureCache($container, $config);
     $this->configureForm($container, $config);
     $this->configureProfiler($container, $config);
     $this->configureException($container, $config);
     $this->configureMenus($container, $config);
     $this->configureClassesToCompile();
     $bundles = $container->getParameter('kernel.bundles');
     if ($config['templates']['block_base'] === null) {
         if (isset($bundles['SonataPageBundle'])) {
             $config['templates']['block_base'] = 'SonataPageBundle:Block:block_base.html.twig';
             $config['templates']['block_container'] = 'SonataPageBundle:Block:block_container.html.twig';
         } else {
             $config['templates']['block_base'] = 'SonataBlockBundle:Block:block_base.html.twig';
             $config['templates']['block_container'] = 'SonataBlockBundle:Block:block_container.html.twig';
         }
     }
     $container->getDefinition('sonata.block.twig.global')->replaceArgument(0, $config['templates']);
 }
 /**
  * {@inheritdoc}
  */
 public function load(array $config, ContainerBuilder $container)
 {
     $processor = new Processor();
     $config = $processor->processConfiguration(new Configuration(), $config);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $configFiles = ['services.xml', 'controller.xml', 'storage.xml', 'routing.xml', 'twig.xml'];
     foreach ($configFiles as $configFile) {
         $loader->load($configFile);
     }
     foreach ($config['resources'] as $alias => $resourceConfig) {
         $metadata = Metadata::fromAliasAndConfiguration($alias, $resourceConfig);
         $resources = $container->hasParameter('sylius.resources') ? $container->getParameter('sylius.resources') : [];
         $resources = array_merge($resources, [$alias => $resourceConfig]);
         $container->setParameter('sylius.resources', $resources);
         DriverProvider::get($metadata)->load($container, $metadata);
         if ($metadata->hasParameter('translation') && class_exists(SyliusTranslationBundle::class)) {
             $alias = $alias . '_translation';
             $resourceConfig = array_merge(['driver' => $resourceConfig['driver']], $resourceConfig['translation']);
             $resources = $container->hasParameter('sylius.resources') ? $container->getParameter('sylius.resources') : [];
             $resources = array_merge($resources, [$alias => $resourceConfig]);
             $container->setParameter('sylius.resources', $resources);
             $metadata = Metadata::fromAliasAndConfiguration($alias, $resourceConfig);
             DriverProvider::get($metadata)->load($container, $metadata);
         }
     }
     $container->setParameter('sylius.resource.settings', $config['settings']);
 }
Example #16
0
 /**
  * Loads the configuration.
  *
  * When the debug flag is true, files in an asset collections will be
  * rendered individually.
  *
  * In XML:
  *
  *     <assetic:config
  *         debug="true"
  *         use-controller="true"
  *         document-root="/path/to/document/root"
  *         closure="/path/to/google_closure/compiler.jar"
  *         yui="/path/to/yuicompressor.jar"
  *         default-javascripts-output="js/build/*.js"
  *         default-stylesheets-output="css/build/*.css"
  *     />
  *
  * In YAML:
  *
  *     assetic:
  *         debug: true
  *         use_controller: true
  *         document_root: /path/to/document/root
  *         closure: /path/to/google_closure/compiler.jar
  *         yui: /path/to/yuicompressor.jar
  *         default_javascripts_output: js/build/*.js
  *         default_stylesheets_output: css/build/*.css
  *
  * @param array            $configs   An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('assetic.xml');
     $loader->load('templating_twig.xml');
     // $loader->load('templating_php.xml'); // not ready yet
     $configuration = new Configuration();
     $processor = new Processor();
     $config = $processor->process($configuration->getConfigTree($container->getParameter('kernel.debug')), $configs);
     $container->setParameter('assetic.debug', $config['debug']);
     $container->setParameter('assetic.use_controller', $config['use_controller']);
     $container->setParameter('assetic.document_root', $config['document_root']);
     $container->setParameter('assetic.default_javascripts_output', $config['default_javascripts_output']);
     $container->setParameter('assetic.default_stylesheets_output', $config['default_stylesheets_output']);
     if (isset($config['closure'])) {
         $container->setParameter('assetic.google_closure_compiler_jar', $config['closure']);
         $loader->load('google_closure_compiler.xml');
     }
     if (isset($config['yui'])) {
         $container->setParameter('assetic.yui_jar', $config['yui']);
         $loader->load('yui_compressor.xml');
     }
     if ($container->getParameterBag()->resolveValue($container->getParameterBag()->get('assetic.use_controller'))) {
         $loader->load('controller.xml');
         $container->setParameter('assetic.twig_extension.class', '%assetic.twig_extension.dynamic.class%');
     } else {
         $loader->load('asset_writer.xml');
         $container->setParameter('assetic.twig_extension.class', '%assetic.twig_extension.static.class%');
     }
     if ($container->hasParameter('assetic.less.compress')) {
         $container->getDefinition('assetic.filter.less')->addMethodCall('setCompress', array('%assetic.less.compress%'));
     }
 }
 /**
  * Load configuration.
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $loader->load('controllers.xml');
     if (isset($config['serializer'])) {
         $container->setAlias('fos_js_routing.serializer', new Alias($config['serializer'], false));
     } else {
         $loader->load('serializer.xml');
     }
     $container->setAlias('fos_js_routing.router', new Alias($config['router'], false));
     $container->getDefinition('fos_js_routing.extractor')->replaceArgument(1, $config['routes_to_expose']);
     if (isset($config['request_context_base_url'])) {
         $container->setParameter('fos_js_routing.request_context_base_url', $config['request_context_base_url']);
     }
     if (isset($config['cache_control'])) {
         $config['cache_control']['enabled'] = true;
     } else {
         $config['cache_control'] = array('enabled' => false);
     }
     $container->setParameter('fos_js_routing.cache_control', $config['cache_control']);
 }
Example #18
0
 /**
  * {@inheritdoc}
  */
 public function parse($value, ManagerRegistry $doctrine)
 {
     if (!is_array($value)) {
         $value = Yaml::parse($value);
     }
     $processor = new Processor();
     $value = $processor->processConfiguration(new QueryConfiguration(), $value);
     if (!isset($value['from'])) {
         throw new InvalidConfigurationException('Missing mandatory "from" section');
     }
     $qb = $this->createQueryBuilder($doctrine, $value);
     foreach ((array) $value['from'] as $from) {
         $qb->from($from['table'], $from['alias']);
     }
     if (isset($value['select'])) {
         foreach ($value['select'] as $select) {
             $qb->add('select', new Expr\Select($select), true);
         }
     }
     if (isset($value['distinct'])) {
         $qb->distinct((bool) $value['distinct']);
     }
     $groupByFields = $this->getGroupByFields($value);
     if ($groupByFields) {
         $qb->groupBy(implode(',', $groupByFields));
     }
     if (isset($value['having'])) {
         $qb->having($value['having']);
     }
     $this->addJoin($qb, $value);
     $this->addWhere($qb, $value);
     $this->addOrder($qb, $value);
     return $qb;
 }
Example #19
0
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->process($configuration->getConfigTree(), $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('model.xml');
     $loader->load('provider.xml');
     $loader->load('sync.xml');
     $loader->load('messenger.xml');
     foreach ($config['feature'] as $feature => $enabled) {
         if ($enabled) {
             $loader->load($feature . '.xml');
         }
     }
     if ($config['feature']['ai']) {
         foreach (array('enabled', 'priority', 'executable_path', 'book_dir') as $option) {
             $container->setParameter('lichess.ai.crafty.' . $option, $config['ai']['crafty'][$option]);
         }
         foreach (array('enabled', 'priority') as $option) {
             $container->setParameter('lichess.ai.stupid.' . $option, $config['ai']['stupid'][$option]);
         }
     }
     $container->setParameter('lichess.debug_assets', $config['debug_assets']);
     $container->setParameter('lichess.sync.path', $config['sync']['path']);
     if ($config['test']) {
         $loader->load('test.xml');
     }
 }
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $providers = $config['providers'];
     foreach ($providers as $key => $providerConfig) {
         // manually make sure "type" is there
         if (!isset($providerConfig['type'])) {
             throw new InvalidConfigurationException(sprintf('Your "knpu_oauth2_client.providers." config entry is missing the "type" key.', $key));
         }
         $type = $providerConfig['type'];
         unset($providerConfig['type']);
         if (!isset(self::$supportedProviderTypes[$type])) {
             throw new InvalidConfigurationException(sprintf('The "knpu_oauth2_client.providers" config "type" key "%s" is not supported. We support (%s)', $type, implode(', ', self::$supportedProviderTypes)));
         }
         // process the configuration
         $tree = new TreeBuilder();
         $node = $tree->root('knpu_oauth2_client/providers/' . $key);
         $this->buildConfigurationForType($node, $type);
         $processor = new Processor();
         $config = $processor->process($tree->buildTree(), array($providerConfig));
         $configurator = $this->getConfigurator($type);
         // hey, we should add the provider service!
         $this->configureProvider($container, $type, $key, $configurator->getProviderClass(), $configurator->getPackagistName(), $configurator->getProviderOptions($config), $config['redirect_route'], $config['redirect_params']);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration($container->getParameter('kernel.debug'));
     $config = $processor->processConfiguration($configuration, $configs);
     $this->loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $this->loader->load('phpcr.xml');
     if (!empty($config['manager_registry_service_id'])) {
         $container->setAlias('doctrine_phpcr', new Alias($config['manager_registry_service_id']));
     }
     $parameters = array('workspace_dir', 'jackrabbit_jar', 'dump_max_line_length');
     foreach ($parameters as $param) {
         if (isset($config[$param])) {
             $container->setParameter('doctrine_phpcr.' . $param, $config[$param]);
         }
     }
     if (!empty($config['session'])) {
         $this->sessionLoad($config['session'], $container);
     }
     if (!empty($config['odm'])) {
         if (empty($this->sessions)) {
             throw new InvalidArgumentException('You did not configure a session for the document managers');
         }
         $this->loadOdm($config['odm'], $container);
         if ($this->disableProxyWarmer) {
             $container->removeDefinition('doctrine_phpcr.odm.proxy_cache_warmer');
         }
     }
     $this->loadTypeGuess($config, $container);
 }
 /**
  * Loads the url shortener configuration.
  *
  * @param array            $configs   An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('cache.xml');
     $loader->load('counter.xml');
     $useOrm = 'auto' == $config['cache_invalidation']['orm_listener'] ? class_exists('Doctrine\\ORM\\Version') : $config['cache_invalidation']['orm_listener'];
     if ($useOrm) {
         $loader->load('orm.xml');
     }
     $usePhpcrOdm = 'auto' == $config['cache_invalidation']['phpcr_odm_listener'] ? class_exists('Doctrine\\PHPCR\\ODM\\Version') : $config['cache_invalidation']['phpcr_odm_listener'];
     if ($usePhpcrOdm) {
         $loader->load('phpcr_odm.xml');
     }
     $this->configureInvalidation($container, $config);
     if ($useOrm) {
         $this->configureORM($container, $config);
     }
     if ($usePhpcrOdm) {
         $this->configurePHPCRODM($container, $config);
     }
     $this->configureCache($container, $config);
     $this->configureCounter($container, $config);
 }
 public function testSingleClientConfigWithOptions()
 {
     $config = ['guzzle' => ['clients' => ['test_client' => ['base_url' => 'http://baseurl/path', 'headers' => ['Accept' => 'application/json'], 'options' => ['cert' => 'path/to/cert', 'connect_timeout' => 5, 'debug' => false, 'decode_content' => true, 'delay' => 1, 'http_errors' => false, 'expect' => true, 'ssl_key' => 'key', 'stream' => true, 'synchronous' => true, 'timeout' => 30, 'verify' => true, 'version' => '1.1'], 'plugin' => ['wsse' => ['username' => 'user', 'password' => 'pass']]]]]];
     $processor = new Processor();
     $processedConfig = $processor->processConfiguration(new Configuration(true), $config);
     $this->assertEquals(array_merge($config['guzzle'], ['logging' => false]), $processedConfig);
 }
 /**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('auto_route.xml');
     $loader->load('token_providers.xml');
     $loader->load('defunct_route_handlers.xml');
     $loader->load('conflict_resolvers.xml');
     $config = $processor->processConfiguration($configuration, $configs);
     $resources = array();
     // auto mapping
     if ($config['auto_mapping']) {
         $bundles = $container->getParameter('kernel.bundles');
         $resources = $this->findMappingFiles($bundles);
     }
     // add configured mapping file resources
     if (isset($config['mapping']['resources'])) {
         foreach ($config['mapping']['resources'] as $resource) {
             $resources[] = $resource;
         }
     }
     $container->setParameter('cmf_routing_auto.metadata.loader.resources', $resources);
     $hasProvider = false;
     if ($this->isConfigEnabled($container, $config['persistence']['phpcr'])) {
         $hasProvider = true;
         $loader->load('phpcr-odm.xml');
         $container->setParameter('cmf_routing_auto.persistence.phpcr.route_basepath', $config['persistence']['phpcr']['route_basepath']);
     }
     if (!$hasProvider) {
         throw new InvalidConfigurationException('The RoutingAUtoBundle requires that you enable one of the persistence layers in your application configuration. ' . 'See the documentation for more information');
     }
 }
 public function testOptions()
 {
     $processor = new Processor();
     $config = $processor->processConfiguration(new Configuration(), array(array('default_contexts' => array('cms'))));
     $expected = array('default_contexts' => array(0 => 'cms'), 'profiler' => array('enabled' => '%kernel.debug%', 'template' => 'SonataBlockBundle:Profiler:block.html.twig', 'container_types' => array(0 => 'sonata.block.service.container', 1 => 'sonata.page.block.container', 2 => 'cmf.block.container', 3 => 'cmf.block.slideshow')), 'context_manager' => 'sonata.block.context_manager.default', 'http_cache' => array('handler' => 'sonata.block.cache.handler.default', 'listener' => true), 'templates' => array('block_base' => NULL, 'block_container' => NULL), 'blocks' => array(), 'menus' => array(), 'blocks_by_class' => array(), 'exception' => array('default' => array('filter' => 'debug_only', 'renderer' => 'throw'), 'filters' => array('debug_only' => 'sonata.block.exception.filter.debug_only', 'ignore_block_exception' => 'sonata.block.exception.filter.ignore_block_exception', 'keep_all' => 'sonata.block.exception.filter.keep_all', 'keep_none' => 'sonata.block.exception.filter.keep_none'), 'renderers' => array('inline' => 'sonata.block.exception.renderer.inline', 'inline_debug' => 'sonata.block.exception.renderer.inline_debug', 'throw' => 'sonata.block.exception.renderer.throw')));
     $this->assertEquals($expected, $config);
 }
 public function testDoNoDuplicateDefaultFormResources()
 {
     $input = array('form_themes' => array('form_div_layout.html.twig'));
     $processor = new Processor();
     $config = $processor->processConfiguration(new Configuration(), array($input));
     $this->assertEquals(array('form_div_layout.html.twig'), $config['form_themes']);
 }
Example #27
0
 /**
  * Validate the configuration file
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return null
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->iohandler_factory->set_environment('cli');
     /** @var \phpbb\install\helper\iohandler\cli_iohandler $iohandler */
     $iohandler = $this->iohandler_factory->get();
     $style = new SymfonyStyle($input, $output);
     $iohandler->set_style($style, $output);
     $config_file = $input->getArgument('config-file');
     if (!is_file($config_file)) {
         $iohandler->add_error_message(array('MISSING_FILE', array($config_file)));
         return 1;
     }
     try {
         $config = Yaml::parse(file_get_contents($config_file), true, false);
     } catch (ParseException $e) {
         $iohandler->add_error_message('INVALID_YAML_FILE');
         return 1;
     }
     $processor = new Processor();
     $configuration = new updater_configuration();
     try {
         $processor->processConfiguration($configuration, $config);
     } catch (Exception $e) {
         $iohandler->add_error_message('INVALID_CONFIGURATION', $e->getMessage());
         return 1;
     }
     $iohandler->add_success_message('CONFIGURATION_VALID');
     return 0;
 }
 /**
  * Responds to the doctrine_mongo_db configuration parameter.
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     // Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('mongodb.xml');
     $processor = new Processor();
     $configuration = new Configuration($container->getParameter('kernel.debug'));
     $config = $processor->processConfiguration($configuration, $configs);
     // can't currently default this correctly in Configuration
     if (!isset($config['metadata_cache_driver'])) {
         $config['metadata_cache_driver'] = array('type' => 'array');
     }
     if (empty($config['default_connection'])) {
         $keys = array_keys($config['connections']);
         $config['default_connection'] = reset($keys);
     }
     if (empty($config['default_document_manager'])) {
         $keys = array_keys($config['document_managers']);
         $config['default_document_manager'] = reset($keys);
     }
     // set some options as parameters and unset them
     $config = $this->overrideParameters($config, $container);
     // load the connections
     $this->loadConnections($config['connections'], $container);
     // load the document managers
     $this->loadDocumentManagers($config['document_managers'], $config['default_document_manager'], $config['default_database'], $config['metadata_cache_driver'], $container);
     $this->loadConstraints($container);
 }
 /**
  * Loads the customer configuration.
  *
  * @param array            $configs   An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $processor = new Processor();
     $configuration = new Configuration();
     $config = $processor->processConfiguration($configuration, $configs);
     $bundles = $container->getParameter('kernel.bundles');
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('block.xml');
     $loader->load('orm.xml');
     $loader->load('form.xml');
     $loader->load('twig.xml');
     if (isset($bundles['FOSRestBundle']) && isset($bundles['NelmioApiDocBundle'])) {
         $loader->load('api_controllers.xml');
         $loader->load('api_form.xml');
         $loader->load('serializer.xml');
     }
     if (isset($bundles['SonataAdminBundle'])) {
         $loader->load('admin.xml');
     }
     if (isset($bundles['SonataSeoBundle'])) {
         $loader->load('seo_block.xml');
     }
     $this->registerDoctrineMapping($config);
     $this->registerParameters($container, $config);
 }
 /**
  * {@inheritdoc}
  */
 public function parse($value, QueryBuilder $qb)
 {
     if (!is_array($value)) {
         $value = Yaml::parse($value);
     }
     $processor = new Processor();
     $value = $processor->processConfiguration(new QueryConfiguration(), $value);
     if (!isset($value['from'])) {
         throw new \RuntimeException('Missing mandatory "from" section');
     }
     foreach ((array) $value['from'] as $from) {
         $qb->from($from['table'], $from['alias']);
     }
     if (isset($value['select'])) {
         foreach ($value['select'] as $select) {
             $qb->add('select', new Expr\Select($select), true);
         }
     }
     if (isset($value['distinct'])) {
         $qb->distinct((bool) $value['distinct']);
     }
     if (isset($value['groupBy'])) {
         $qb->groupBy($value['groupBy']);
     }
     if (isset($value['having'])) {
         $qb->having($value['having']);
     }
     $this->addJoin($qb, $value);
     $this->addWhere($qb, $value);
     $this->addOrder($qb, $value);
     return $qb;
 }