Exemplo n.º 1
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->process($configuration->getConfigTree(), $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);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider getNormalizationTests
  */
 public function testNormalizeOptions(array $config, $targetKey, array $normalized)
 {
     $processor = new Processor();
     $configuration = new Configuration(false);
     $options = $processor->process($configuration->getConfigTree(), array($config));
     $this->assertSame($normalized, $options[$targetKey]);
 }