예제 #1
0
 public function mongodbLoad($config, BuilderConfiguration $configuration)
 {
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['mongodb']));
     if (!$configuration->hasDefinition('doctrine.odm.mongodb.document_manager')) {
         $configuration->setParameter('doctrine.odm.mongodb.mapping_dirs', $this->findBundleSubpaths('Resources/config/doctrine/metadata', $configuration));
         $configuration->setParameter('doctrine.odm.mongodb.document_dirs', $this->findBundleSubpaths('Document', $configuration));
         $configuration->setDefinition('doctrine.odm.mongodb.metadata', $this->buildMetadataDefinition($configuration));
     }
     foreach (array('host', 'port', 'database') as $key) {
         if (isset($config[$key])) {
             $configuration->setParameter('doctrine.odm.mongodb.default_' . $key, $config[$key]);
         }
     }
     foreach (array('proxy_dir', 'auto_generate_proxy_classes') as $key) {
         if (isset($config[$key])) {
             $configuration->setParameter('doctrine.odm.mongodb.' . $key, $config[$key]);
         }
     }
     foreach (array('cache', 'metadata') as $key) {
         if (isset($config[$key])) {
             $configuration->setAlias('doctrine.odm.mongodb.' . $key, 'doctrine.odm.mongodb.' . $key . '.' . $config[$key]);
         }
     }
 }
 public function testDbalLoadFromXmlMultipleConnections()
 {
     $container = new ContainerBuilder();
     $loader = $this->getDoctrineExtensionLoader();
     $container->registerExtension($loader);
     $loadXml = new XmlFileLoader($container, __DIR__ . '/Fixtures/config/xml');
     $loadXml->load('dbal_service_multiple_connections.xml');
     $loader->dbalLoad(array(), $container);
     $container->freeze();
     // doctrine.dbal.mysql_connection
     $arguments = $container->getDefinition('doctrine.dbal.mysql_connection')->getArguments();
     $config = $arguments[0];
     $this->assertEquals('mysql_s3cr3t', $config['password']);
     $this->assertEquals('mysql_user', $config['user']);
     $this->assertEquals('mysql_db', $config['dbname']);
     $this->assertEquals('/path/to/mysqld.sock', $config['unix_socket']);
     // doctrine.dbal.sqlite_connection
     $arguments = $container->getDefinition('doctrine.dbal.sqlite_connection')->getArguments();
     $container = new ContainerBuilder();
     $loader = $this->getDoctrineExtensionLoader();
     $container->registerExtension($loader);
     $loadXml = new XmlFileLoader($container, __DIR__ . '/Fixtures/config/xml');
     $loadXml->load('dbal_service_single_connection.xml');
     $loader->dbalLoad(array(), $container);
     $container->freeze();
     // doctrine.dbal.mysql_connection
     $arguments = $container->getDefinition('doctrine.dbal.mysql_connection')->getArguments();
     $config = $arguments[0];
     $this->assertEquals('mysql_s3cr3t', $config['password']);
     $this->assertEquals('mysql_user', $config['user']);
     $this->assertEquals('mysql_db', $config['dbname']);
     $this->assertEquals('/path/to/mysqld.sock', $config['unix_socket']);
 }
 /**
  * Loads the Doctrine ORM configuration.
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function ormLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['orm']));
     return $configuration;
 }
예제 #4
0
 /**
  * Loads the session configuration.
  *
  * @param array                $config        A configuration array
  * @param BuilderConfiguration $configuration A BuilderConfiguration instance
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function sessionLoad($config, BuilderConfiguration $configuration)
 {
     if (!$configuration->hasDefinition('session')) {
         $loader = new XmlFileLoader(array(__DIR__ . '/../Resources/config', __DIR__ . '/Resources/config'));
         $configuration->merge($loader->load('session.xml'));
     }
     if (isset($config['default_locale'])) {
         $configuration->setParameter('session.default_locale', $config['default_locale']);
     }
     if (isset($config['class'])) {
         $configuration->setParameter('session.class', $config['class']);
     }
     foreach (array('name', 'auto_start', 'lifetime', 'path', 'domain', 'secure', 'httponly', 'cache_limiter', 'pdo.db_table') as $name) {
         if (isset($config['session'][$name])) {
             $configuration->setParameter('session.options.' . $name, $config['session'][$name]);
         }
     }
     if (isset($config['session']['class'])) {
         $class = $config['session']['class'];
         if (in_array($class, array('Native', 'Pdo'))) {
             $class = 'Symfony\\Framework\\FrameworkBundle\\SessionStorage\\' . $class . 'SessionStorage';
         }
         $configuration->setParameter('session.session', 'session.session.' . strtolower($class));
     }
     return $configuration;
 }
예제 #5
0
 public function configLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load('twig.xml'));
     $configuration->setParameter('twig_options', array_replace($configuration->getParameter('twig_options'), $config));
     return $configuration;
 }
예제 #6
0
 public function buildContainer(ContainerInterface $container)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/Resources/config');
     $configuration->merge($loader->load('config.xml'));
     $configuration->merge($loader->load('logger.xml'));
     return $configuration;
 }
예제 #7
0
 public function configLoad($config, BuilderConfiguration $configuration)
 {
     if (!$configuration->hasDefinition('twig')) {
         $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
         $configuration->merge($loader->load('twig.xml'));
     }
     $configuration->setParameter('twig.options', array_replace($configuration->getParameter('twig.options'), $config));
 }
예제 #8
0
 public function testLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(array(__DIR__ . '/../Resources/config', __DIR__ . '/Resources/config'));
     $configuration->merge($loader->load('test.xml'));
     $configuration->setParameter('kernel.include_core_classes', false);
     return $configuration;
 }
예제 #9
0
 /**
  * Loads the Twig configuration.
  *
  * @param array                                                        $config        An array of configuration settings
  * @param \Symfony\Components\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
  */
 public function configLoad($config, ContainerBuilder $container)
 {
     if (!$container->hasDefinition('twig')) {
         $loader = new XmlFileLoader($container, __DIR__ . '/../Resources/config');
         $loader->load('twig.xml');
     }
     $container->setParameter('twig.options', array_replace($container->getParameter('twig.options'), $config));
 }
예제 #10
0
 public function odmLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $defaultConfiguration = array_merge(array('connection' => 'mongodb://localhost:27017', 'params' => array('connected' => true)), $config);
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->setParameter('mongo.connection', $defaultConfiguration['connection']);
     $configuration->setParameter('mongo.params', $defaultConfiguration['params']);
     $configuration->merge($loader->load($this->resources['odm']));
     return $configuration;
 }
예제 #11
0
 public function configLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load('collectors.xml'));
     if (isset($config['toolbar']) && $config['toolbar']) {
         $configuration->merge($loader->load('toolbar.xml'));
     }
     return $configuration;
 }
예제 #12
0
 /**
  * Loads the Swift Mailer configuration.
  *
  * Usage example:
  *
  *      <swift:mailer transport="gmail" delivery_strategy="spool">
  *        <swift:username>fabien</swift:username>
  *        <swift:password>xxxxx</swift:password>
  *        <swift:spool path="/path/to/spool/" />
  *      </swift:mailer>
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function mailerLoad($config, BuilderConfiguration $configuration)
 {
     if (!$configuration->hasDefinition('swiftmailer.mailer')) {
         $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
         $configuration->merge($loader->load($this->resources['mailer']));
         $configuration->setAlias('mailer', 'swiftmailer.mailer');
     }
     $r = new \ReflectionClass('Swift_Message');
     $configuration->setParameter('swiftmailer.base_dir', dirname(dirname(dirname($r->getFilename()))));
     $transport = $configuration->getParameter('swiftmailer.transport.name');
     if (array_key_exists('transport', $config)) {
         if (null === $config['transport']) {
             $transport = 'null';
         } elseif ('gmail' === $config['transport']) {
             $config['encryption'] = 'ssl';
             $config['auth_mode'] = 'login';
             $config['host'] = 'smtp.gmail.com';
             $transport = 'smtp';
         } else {
             $transport = $config['transport'];
         }
         $configuration->setParameter('swiftmailer.transport.name', $transport);
     }
     $configuration->setAlias('swiftmailer.transport', 'swiftmailer.transport.' . $transport);
     if (isset($config['encryption']) && 'ssl' === $config['encryption'] && !isset($config['port'])) {
         $config['port'] = 465;
     }
     foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode') as $key) {
         if (isset($config[$key])) {
             $configuration->setParameter('swiftmailer.transport.' . $transport . '.' . $key, $config[$key]);
         }
     }
     // spool?
     if (isset($config['spool'])) {
         $type = isset($config['type']) ? $config['type'] : 'file';
         $configuration->setAlias('swiftmailer.transport.real', 'swiftmailer.transport.' . $transport);
         $configuration->setAlias('swiftmailer.transport', 'swiftmailer.transport.spool');
         $configuration->setAlias('swiftmailer.spool', 'swiftmailer.spool.' . $type);
         foreach (array('path') as $key) {
             if (isset($config['spool'][$key])) {
                 $configuration->setParameter('swiftmailer.spool.' . $type . '.' . $key, $config['spool'][$key]);
             }
         }
     }
     if (isset($config['delivery_address'])) {
         $configuration->setParameter('swiftmailer.single_address', $config['delivery_address']);
         $configuration->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.redirecting')));
     }
     if (isset($config['disable_delivery']) && $config['disable_delivery']) {
         $configuration->findDefinition('swiftmailer.transport')->addMethodCall('registerPlugin', array(new Reference('swiftmailer.plugin.blackhole')));
     }
     return $configuration;
 }
예제 #13
0
 /**
  * Customizes the Container instance.
  *
  * @param Symfony\Components\DependencyInjection\ContainerInterface $container A ContainerInterface instance
  *
  * @return Symfony\Components\DependencyInjection\BuilderConfiguration A BuilderConfiguration instance
  */
 public function buildContainer(ContainerInterface $container)
 {
     Loader::registerExtension(new KernelExtension());
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(array(__DIR__ . '/../Resources/config', __DIR__ . '/Resources/config'));
     $configuration->merge($loader->load('services.xml'));
     if ($container->getParameter('kernel.debug')) {
         $configuration->merge($loader->load('debug.xml'));
         $configuration->setDefinition('event_dispatcher', $configuration->findDefinition('debug.event_dispatcher'));
     }
     return $configuration;
 }
예제 #14
0
 /**
  * Customizes the Container instance.
  *
  * @param \Symfony\Components\DependencyInjection\ParameterBag\ParameterBagInterface $parameterBag A ParameterBagInterface instance
  *
  * @return \Symfony\Components\DependencyInjection\ContainerBuilder A ContainerBuilder instance
  */
 public function buildContainer(ParameterBagInterface $parameterBag)
 {
     ContainerBuilder::registerExtension(new KernelExtension());
     $container = new ContainerBuilder();
     $loader = new XmlFileLoader($container, array(__DIR__ . '/../Resources/config', __DIR__ . '/Resources/config'));
     $loader->load('services.xml');
     if ($parameterBag->get('kernel.debug')) {
         $loader->load('debug.xml');
         $container->setDefinition('event_dispatcher', $container->findDefinition('debug.event_dispatcher'));
     }
     return $container;
 }
예제 #15
0
 /**
  * Loads the logger configuration.
  *
  * Usage example:
  *
  *      <zend:logger priority="info" path="/path/to/some.log" />
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function loggerLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['logger']));
     if (isset($config['priority'])) {
         $configuration->setParameter('zend.logger.priority', is_int($config['priority']) ? $config['priority'] : constant('\\Zend_Log::' . strtoupper($config['priority'])));
     }
     if (isset($config['path'])) {
         $configuration->setParameter('zend.logger.path', $config['path']);
     }
     $configuration->setAlias('logger', 'zend.logger');
     return $configuration;
 }
예제 #16
0
 /**
  * Loads the logger configuration.
  *
  * Usage example:
  *
  *      <zend:logger priority="info" path="/path/to/some.log" />
  *
  * @param array                $config        A configuration array
  * @param BuilderConfiguration $configuration A BuilderConfiguration instance
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function loggerLoad($config, BuilderConfiguration $configuration)
 {
     if (!$configuration->hasDefinition('zend.logger')) {
         $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
         $configuration->merge($loader->load($this->resources['logger']));
         $configuration->setAlias('logger', 'zend.logger');
     }
     if (isset($config['priority'])) {
         $configuration->setParameter('zend.logger.priority', is_int($config['priority']) ? $config['priority'] : constant('\\Zend\\Log\\Logger::' . strtoupper($config['priority'])));
     }
     if (isset($config['path'])) {
         $configuration->setParameter('zend.logger.path', $config['path']);
     }
 }
예제 #17
0
 /**
  * Customizes the Container instance.
  *
  * @param Symfony\Components\DependencyInjection\ContainerInterface $container A ContainerInterface instance
  *
  * @return Symfony\Components\DependencyInjection\BuilderConfiguration A BuilderConfiguration instance
  */
 public function buildContainer(ContainerInterface $container)
 {
     Loader::registerExtension(new WebExtension($container->getParameter('kernel.bundle_dirs'), $container->getParameter('kernel.bundles')));
     $dirs = array('%kernel.root_dir%/views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%');
     foreach ($container->getParameter('kernel.bundle_dirs') as $dir) {
         $dirs[] = $dir . '/%%bundle%%/Resources/views/%%controller%%/%%name%%%%format%%.%%renderer%%';
     }
     $container->setParameter('templating.loader.filesystem.path', $dirs);
     $configuration = new BuilderConfiguration();
     if ($container->getParameter('kernel.debug')) {
         $loader = new XmlFileLoader(__DIR__ . '/Resources/config');
         $configuration->merge($loader->load('debug.xml'));
     }
     return $configuration;
 }
예제 #18
0
 /**
  * Loads the default configuration.
  *
  * @param array $config An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 protected function loadDefaults(array $config, ContainerBuilder $container)
 {
     // Load DoctrineMongoDBBundle/Resources/config/mongodb.xml
     $loader = new XmlFileLoader($container, __DIR__ . '/../Resources/config');
     $loader->load($this->resources['mongodb']);
     // Allow these application configuration options to override the defaults
     $options = array('default_document_manager', 'default_connection', 'cache_driver', 'metadata_cache_driver', 'proxy_namespace', 'auto_generate_proxy_classes');
     foreach ($options as $key) {
         if (isset($config[$key])) {
             $container->setParameter('doctrine.odm.mongodb.' . $key, $config[$key]);
         }
     }
     $container->setParameter('doctrine.odm.mongodb.mapping_dirs', $this->findBundleSubpaths('Resources/config/doctrine/metadata', $container));
     $container->setParameter('doctrine.odm.mongodb.document_dirs', $this->findBundleSubpaths('Document', $container));
 }
예제 #19
0
 public function debugLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['debug']));
     if (isset($config['exception']) && $config['exception']) {
         $configuration->merge($loader->load('debug_exception_handler.xml'));
     }
     if (isset($config['toolbar']) && $config['toolbar']) {
         $configuration->merge($loader->load('debug_data_collector.xml'));
         $configuration->merge($loader->load('debug_web_debug_toolbar.xml'));
     }
     if (isset($config['ide']) && 'textmate' === $config['ide']) {
         $configuration->setParameter('web_debug.file_link_format', 'txmt://open?url=file://%%f&line=%%l');
     }
     $configuration->setAlias('event_dispatcher', 'debug.event_dispatcher');
     return $configuration;
 }
예제 #20
0
 public function slideshareLoad($config, ContainerBuilder $container)
 {
     if (!$container->hasDefinition('slideshare')) {
         $loader = new XmlFileLoader($container, __DIR__ . '/../Resources/config');
         $loader->load($this->resources['slideshare']);
     }
     if (isset($config['url'])) {
         $container->setParameter('news.slideshare.url', $config['url']);
     }
     if (isset($config['api_key'])) {
         $container->setParameter('news.slideshare.api_key', $config['api_key']);
     }
     if (isset($config['api_secret'])) {
         $container->setParameter('news.slideshare.api_secret', $config['api_secret']);
     }
     if (isset($config['search_query'])) {
         $container->setParameter('news.slideshare.search_query', $config['search_query']);
     }
 }
예제 #21
0
 /**
  * Loads the DBAL configuration.
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function dbalLoad($config, BuilderConfiguration $configuration)
 {
     if (!$configuration->hasDefinition('propel')) {
         $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
         $configuration->merge($loader->load($this->resources['propel']));
     }
     $defaultConnection = array('driver' => 'mysql', 'user' => 'root', 'password' => null, 'dsn' => null, 'classname' => 'DebugPDO', 'options' => array(), 'attributes' => array(), 'settings' => array('charset' => array('value' => 'UTF8')));
     $defaultConnectionName = isset($config['default_connection']) ? $config['default_connection'] : $configuration->getParameter('propel.dbal.default_connection');
     $configuration->setParameter('propel.dbal.default_connection', $defaultConnectionName);
     $connections = array();
     if (isset($config['connections'])) {
         foreach ($config['connections'] as $name => $connection) {
             $connections[isset($connection['id']) ? $connection['id'] : $name] = $connection;
         }
     } else {
         $connections = array($defaultConnectionName => $config);
     }
     $arguments = $configuration->getDefinition('propel.configuration')->getArguments();
     if (count($arguments)) {
         $c = $arguments[0];
     } else {
         $c = array('log' => array('level' => 7), 'datasources' => array());
     }
     foreach ($connections as $name => $connection) {
         if (isset($c['datasources'][$name])) {
         } else {
             $connection = array_replace($defaultConnection, $connection);
             $c['datasources'][$name] = array('connection' => array());
         }
         if (isset($connection['driver'])) {
             $c['datasources'][$name]['adapter'] = $connection['driver'];
         }
         foreach (array('dsn', 'user', 'password', 'classname', 'options', 'attributes', 'settings') as $att) {
             if (isset($connection[$att])) {
                 $c['datasources'][$name]['connection'][$att] = $connection[$att];
             }
         }
     }
     $configuration->getDefinition('propel.configuration')->setArguments(array($c));
     return $configuration;
 }
예제 #22
0
 /**
  * Loads the i18n configuration.
  *
  * Usage example:
  *
  *      <zend:i18n locale="en" adapter="xliff" data="/path/to/messages.xml" />
  *
  * @param array $config An array of configuration settings
  * @param \Symfony\Components\DependencyInjection\ContainerBuilder $container A ContainerBuilder instance
  */
 public function i18nLoad($config, ContainerBuilder $container)
 {
     if (!$container->hasDefinition('zend.i18n')) {
         $loader = new XmlFileLoader($container, __DIR__ . '/../Resources/config');
         $loader->load($this->resources['i18n']);
         $container->setAlias('i18n', 'zend.i18n');
     }
     if (isset($config['locale'])) {
         $container->setParameter('zend.translator.locale', $config['locale']);
     }
     if (isset($config['adapter'])) {
         $container->setParameter('zend.translator.adapter', constant($config['adapter']));
     }
     if (isset($config['translations']) && is_array($config['translations'])) {
         foreach ($config['translations'] as $locale => $catalogue) {
             if ($locale == $container->getParameter('zend.translator.locale')) {
                 $container->setParameter('zend.translator.catalogue', $catalogue);
             }
             $container->findDefinition('zend.translator')->addMethodCall('addTranslation', array($catalogue, $locale));
         }
     }
 }
 /**
  * Loads the Swift Mailer configuration.
  *
  * Usage example:
  *
  *      <swift:mailer transport="gmail" delivery_strategy="spool">
  *        <swift:username>fabien</swift:username>
  *        <swift:password>xxxxx</swift:password>
  *        <swift:spool path="/path/to/spool/" />
  *      </swift:mailer>
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function mailerLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['mailer']));
     if (isset($config['transport']) && null === $config['transport']) {
         $config['transport'] = 'null';
     } elseif (!isset($config['transport'])) {
         $config['transport'] = 'smtp';
     } elseif ('gmail' === $config['transport']) {
         $config['encryption'] = 'ssl';
         $config['auth_mode'] = 'login';
         $config['host'] = 'smtp.gmail.com';
         $config['transport'] = 'smtp';
     }
     $configuration->setAlias('swiftmailer.transport', 'swiftmailer.transport.' . $config['transport']);
     if (isset($config['encryption']) && 'ssl' === $config['encryption'] && !isset($config['port'])) {
         $config['port'] = 465;
     }
     foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode') as $key) {
         if (isset($config[$key])) {
             $configuration->setParameter('swiftmailer.transport.' . $config['transport'] . '.' . $key, $config[$key]);
         }
     }
     // spool?
     if (isset($config['spool'])) {
         $type = isset($config['type']) ? $config['type'] : 'file';
         $configuration->setAlias('swiftmailer.transport.real', 'swiftmailer.transport.' . $config['transport']);
         $configuration->setAlias('swiftmailer.transport', 'swiftmailer.transport.spool');
         $configuration->setAlias('swiftmailer.spool', 'swiftmailer.spool.' . $type);
         foreach (array('path') as $key) {
             if (isset($config['spool'][$key])) {
                 $configuration->setParameter('swiftmailer.spool.' . $type . '.' . $key, $config['spool'][$key]);
             }
         }
     }
     $configuration->setAlias('mailer', 'swiftmailer.mailer');
     return $configuration;
 }
예제 #24
0
 /**
  * Loads the DBAL configuration.
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function dbalLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['propel']));
     $defaultConnection = array('driver' => 'mysql', 'user' => 'root', 'password' => null, 'dsn' => null, 'classname' => 'DebugPDO', 'options' => array(), 'attributes' => array(), 'settings' => array('charset' => array('value' => 'UTF8')));
     $config['default_connection'] = isset($config['default_connection']) ? $config['default_connection'] : 'default';
     $connections = array();
     if (isset($config['connections'])) {
         foreach ($config['connections'] as $name => $connection) {
             $connections[isset($connection['id']) ? $connection['id'] : $name] = $connection;
         }
     } else {
         $connections = array($config['default_connection'] => $config);
     }
     $c = array('log' => array('level' => 7), 'datasources' => array());
     foreach ($connections as $name => $connection) {
         $connection = array_replace($defaultConnection, $connection);
         $c['datasources'][$name] = array('adapter' => $connection['driver'], 'connection' => array('dsn' => $connection['dsn'], 'user' => $connection['user'], 'password' => $connection['password'], 'classname' => $connection['classname'], 'options' => $connection['options'], 'attributes' => $connection['attributes'], 'settings' => $connection['settings']));
     }
     $configuration->getDefinition('propel.configuration')->setArguments(array($c));
     return $configuration;
 }
예제 #25
0
 /**
  * Loads the templating configuration.
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function templatingLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['templating']));
     $configuration->setParameter('templating.output_escaper', array_key_exists('escaping', $config) ? $config['escaping'] : false);
     $configuration->setParameter('templating.assets.version', array_key_exists('assets_version', $config) ? $config['assets_version'] : null);
     // path for the filesystem loader
     if (isset($config['path'])) {
         $configuration->setParameter('templating.loader.filesystem.path', $config['path']);
     }
     // loaders
     if (isset($config['loader'])) {
         $loaders = array();
         $ids = is_array($config['loader']) ? $config['loader'] : array($config['loader']);
         foreach ($ids as $id) {
             $loaders[] = new Reference($id);
         }
     } else {
         $loaders = array(new Reference('templating.loader.filesystem'));
     }
     if (1 === count($loaders)) {
         $configuration->setAlias('templating.loader', (string) $loaders[0]);
     } else {
         $configuration->getDefinition('templating.loader.chain')->addArgument($loaders);
         $configuration->setAlias('templating.loader', 'templating.loader.chain');
     }
     // cache?
     if (isset($config['cache'])) {
         // wrap the loader with some cache
         $configuration->setDefinition('templating.loader.wrapped', $configuration->findDefinition('templating.loader'));
         $configuration->setDefinition('templating.loader', $configuration->getDefinition('templating.loader.cache'));
         $configuration->setParameter('templating.loader.cache.path', $config['cache']);
     }
     return $configuration;
 }
예제 #26
0
 public function configLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(array(__DIR__ . '/../Resources/config', __DIR__ . '/Resources/config'));
     $configuration->merge($loader->load('services.xml'));
     if (isset($config['charset'])) {
         $configuration->setParameter('kernel.charset', $config['charset']);
     }
     if (!array_key_exists('compilation', $config)) {
         $classes = array('Symfony\\Components\\Routing\\Router', 'Symfony\\Components\\Routing\\RouterInterface', 'Symfony\\Components\\EventDispatcher\\Event', 'Symfony\\Components\\Routing\\Matcher\\UrlMatcherInterface', 'Symfony\\Components\\Routing\\Matcher\\UrlMatcher', 'Symfony\\Components\\RequestHandler\\RequestInterface', 'Symfony\\Components\\RequestHandler\\Request', 'Symfony\\Components\\RequestHandler\\RequestHandler', 'Symfony\\Components\\RequestHandler\\ResponseInterface', 'Symfony\\Components\\RequestHandler\\Response', 'Symfony\\Components\\Templating\\Loader\\LoaderInterface', 'Symfony\\Components\\Templating\\Loader\\Loader', 'Symfony\\Components\\Templating\\Loader\\FilesystemLoader', 'Symfony\\Components\\Templating\\Engine', 'Symfony\\Components\\Templating\\Renderer\\RendererInterface', 'Symfony\\Components\\Templating\\Renderer\\Renderer', 'Symfony\\Components\\Templating\\Renderer\\PhpRenderer', 'Symfony\\Components\\Templating\\Storage\\Storage', 'Symfony\\Components\\Templating\\Storage\\FileStorage', 'Symfony\\Framework\\WebBundle\\Controller', 'Symfony\\Framework\\WebBundle\\Listener\\RequestParser', 'Symfony\\Framework\\WebBundle\\Listener\\ControllerLoader', 'Symfony\\Framework\\WebBundle\\Listener\\ResponseFilter', 'Symfony\\Framework\\WebBundle\\Templating\\Engine');
     } else {
         $classes = array();
         foreach (explode("\n", $config['compilation']) as $class) {
             if ($class) {
                 $classes[] = trim($class);
             }
         }
     }
     $configuration->setParameter('kernel.compiled_classes', $classes);
     if (array_key_exists('error_handler_level', $config)) {
         $configuration->setParameter('error_handler.level', $config['error_handler_level']);
     }
     return $configuration;
 }
예제 #27
0
 /**
  * @param array $config
  * @param Symfony\Components\DependencyInjection\BuilderConfiguration $configuration
  * @return Symfony\Components\DependencyInjection\BuilderConfiguration
  *
  * @throws \InvalidArgumentException If Server class does not implement ServerInterface
  */
 public function serverLoad(array $config, BuilderConfiguration $configuration)
 {
     if (!$configuration->hasDefinition('server')) {
         $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
         $configuration->merge($loader->load($this->resources['server']));
     }
     // Options
     $options = array('pid_file', 'user', 'group', 'umask', 'hostname', 'admin', 'hostname_lookups', 'max_clients', 'max_requests_per_child', 'address', 'port', 'timeout', 'keepalive_timeout', 'compression', 'compression_level');
     // General
     foreach ($options as $name) {
         if (!array_key_exists($name, $config)) {
             continue;
         }
         $configuration->setParameter(sprintf('server.%s', $name), $config[$name]);
     }
     // Classes
     if (isset($config['class'])) {
         $this->checkServiceClassInterface('Server', $config['class'], 'Bundle\\ServerBundle\\ServerInterface');
         $configuration->setParameter('server.class', $config['class']);
     }
     if (isset($config['request'])) {
         $this->checkServiceClassInterface('Request', $config['request'], 'Bundle\\ServerBundle\\RequestInterface');
         $configuration->setParameter('server.request.class', $config['request']);
     }
     if (isset($config['response'])) {
         $this->checkServiceClassInterface('Response', $config['response'], 'Bundle\\ServerBundle\\ResponseInterface');
         $configuration->setParameter('server.response.class', $config['response']);
     }
     // Handlers
     if (isset($config['handlers'])) {
         if (!is_array($config['handlers'])) {
             throw new \InvalidArgumentException(sprintf('Handler configuration must be of type array, "%s" given', gettype($config['handlers'])));
         }
         foreach ($config['handlers'] as $handler) {
             // @TODO: configure handlers
             // $this->checkServiceClassInterface('Handler', $handler['class'], 'Bundle\\ServerBundle\\Handler\\HandlerInterface');
         }
     }
     // Handler configuration
     if (isset($config['environment'])) {
         $configuration->setParameter('server.kernel_environment', $config['environment']);
         // fixes class redeclaration error on custom kernel environment
         if ($config['environment'] != $this->container->getParameter('kernel.environment')) {
             $configuration->setParameter('kernel.include_core_classes', false);
         }
     }
     if (array_key_exists('debug', $config)) {
         $configuration->setParameter('server.kernel_debug', $config['debug']);
         // fixes class redeclaration error on custom kernel debug mode
         if ($config['debug'] != $this->container->getParameter('kernel.debug')) {
             $configuration->setParameter('kernel.include_core_classes', false);
         }
     }
     // Filters
     if (isset($config['filters'])) {
         if (!is_array($config['filters'])) {
             throw new \InvalidArgumentException(sprintf('Filter configuration must be of type array, "%s" given', gettype($config['filters'])));
         }
         foreach ($config['filters'] as $filter) {
             // @TODO: configure filters
             // $this->checkServiceClassInterface('Filter', $filter['class'], 'Bundle\\ServerBundle\\Filter\\FilterInterface');
         }
     }
     // Filter configuration
     return $configuration;
 }
예제 #28
0
 /**
  * Loads the ORM default configuration.
  *
  * @param array $config An array of configuration settings
  * @param ContainerBuilder $container A ContainerBuilder instance
  */
 protected function loadOrmDefaults(array $config, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, __DIR__ . '/../Resources/config');
     $loader->load($this->resources['orm']);
     // Allow these application configuration options to override the defaults
     $options = array('default_entity_manager', 'default_connection', 'metadata_cache_driver', 'query_cache_driver', 'result_cache_driver', 'proxy_namespace', 'auto_generate_proxy_classes');
     foreach ($options as $key) {
         if (isset($config[$key])) {
             $container->setParameter('doctrine.orm.' . $key, $config[$key]);
         }
     }
     $container->setParameter('doctrine.orm.mapping_dirs', $this->findBundleSubpaths('Resources/config/doctrine/metadata', $container));
     $container->setParameter('doctrine.orm.entity_dirs', $this->findBundleSubpaths('Entity', $container));
 }
예제 #29
0
 /**
  * Loads the Doctrine ORM configuration.
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function ormLoad($config)
 {
     $configuration = new BuilderConfiguration();
     $loader = new XmlFileLoader(__DIR__ . '/../Resources/config');
     $configuration->merge($loader->load($this->resources['orm']));
     $config['default_entity_manager'] = isset($config['default_entity_manager']) ? $config['default_entity_manager'] : 'default';
     foreach (array('metadata_driver', 'cache_driver') as $key) {
         if (isset($config[$key])) {
             $configuration->setParameter('doctrine.orm.' . $key, $config[$key]);
         }
     }
     $config['entity_managers'] = isset($config['entity_managers']) ? $config['entity_managers'] : array($config['default_entity_manager'] => array());
     foreach ($config['entity_managers'] as $name => $connection) {
         $ormConfigDef = new Definition('Doctrine\\ORM\\Configuration');
         $configuration->setDefinition(sprintf('doctrine.orm.%s_configuration', $name), $ormConfigDef);
         $drivers = array('metadata', 'query', 'result');
         foreach ($drivers as $driver) {
             $definition = $configuration->getDefinition(sprintf('doctrine.orm.cache.%s', $configuration->getParameter('doctrine.orm.cache_driver')));
             $clone = clone $definition;
             $clone->addMethodCall('setNamespace', array(sprintf('doctrine_%s_', $driver)));
             $configuration->setDefinition(sprintf('doctrine.orm.%s_cache', $driver), $clone);
         }
         // configure metadata driver for each bundle based on the type of mapping files found
         $mappingDriverDef = new Definition('Doctrine\\ORM\\Mapping\\Driver\\DriverChain');
         $bundleEntityMappings = array();
         $bundleDirs = $this->bundleDirs;
         $aliasMap = array();
         foreach (array_reverse($this->bundles) as $className) {
             $tmp = dirname(str_replace('\\', '/', $className));
             $namespace = str_replace('/', '\\', dirname($tmp));
             $class = basename($tmp);
             if (!isset($bundleDirs[$namespace])) {
                 continue;
             }
             $type = false;
             if (is_dir($dir = $bundleDirs[$namespace] . '/' . $class . '/Resources/config/doctrine/metadata')) {
                 $type = $this->detectMappingType($dir);
             }
             if (is_dir($dir = $bundleDirs[$namespace] . '/' . $class . '/Entities')) {
                 if ($type === false) {
                     $type = 'annotation';
                 }
                 $aliasMap[$class] = $namespace . '\\' . $class . '\\Entities';
             }
             if (false !== $type) {
                 $mappingDriverDef->addMethodCall('addDriver', array(new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)), $namespace . '\\' . $class . '\\Entities'));
             }
         }
         $ormConfigDef->addMethodCall('setEntityNamespaces', array($aliasMap));
         $configuration->setDefinition('doctrine.orm.metadata_driver', $mappingDriverDef);
         $methods = array('setMetadataCacheImpl' => new Reference('doctrine.orm.metadata_cache'), 'setQueryCacheImpl' => new Reference('doctrine.orm.query_cache'), 'setResultCacheImpl' => new Reference('doctrine.orm.result_cache'), 'setMetadataDriverImpl' => new Reference('doctrine.orm.metadata_driver'), 'setProxyDir' => '%kernel.cache_dir%/doctrine/Proxies', 'setProxyNamespace' => 'Proxies', 'setAutoGenerateProxyClasses' => true);
         foreach ($methods as $method => $arg) {
             $ormConfigDef->addMethodCall($method, array($arg));
         }
         $ormEmArgs = array(new Reference(sprintf('doctrine.dbal.%s_connection', isset($connection['connection']) ? $connection['connection'] : $name)), new Reference(sprintf('doctrine.orm.%s_configuration', $name)));
         $ormEmDef = new Definition('Doctrine\\ORM\\EntityManager', $ormEmArgs);
         $ormEmDef->setConstructor('create');
         $configuration->setDefinition(sprintf('doctrine.orm.%s_entity_manager', $name), $ormEmDef);
         if ($name == $config['default_entity_manager']) {
             $configuration->setAlias('doctrine.orm.entity_manager', sprintf('doctrine.orm.%s_entity_manager', $name));
         }
     }
     $configuration->setAlias('doctrine.orm.cache', sprintf('doctrine.orm.cache.%s', $configuration->getParameter('doctrine.orm.cache_driver')));
     return $configuration;
 }
예제 #30
0
 public function parseFile($file)
 {
     return parent::parseFile($file);
 }