php Symfony-Component-DependencyInjection-Loader-XmlFileLoader类(方法)实例源码

下面列出了php Symfony-Component-DependencyInjection-Loader-XmlFileLoader 类(方法)源码代码实例,从而了解它的用法。

作者:spin7io    项目:JonlilCKFinderBundl   
/**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     foreach (array('services', 'form') as $service) {
         $loader->load(sprintf('%s.xml', $service));
     }
     if ($config['service'] == 's3') {
         $loader->load('s3.xml');
     } else {
         $loader->load('connector.xml');
     }
     switch ($config['service']) {
         case 'php':
             $container->setAlias('jonlil_ckfinder.connector', 'jonlil.ckfinder.connector.php');
             break;
         case 's3':
             $container->setAlias('jonlil_ckfinder.connector', 'jonlil.ckfinder.connector.s3');
             $container->setParameter('jonlil_ckfinder.amazon', array('secret' => $config['secret'], 'bucket' => $config['bucket'], 'access_key' => $config['accessKey'], 'base_url' => $config['baseUrl'], 'base_dir' => $config['baseDir'], 'thumbnails_file' => $config['thumbnailsFile'], 'thumbnails_enabled' => $config['thumbnailsEnabled'], 'direct_access' => $config['directAccess'], 'file_delete' => $config['fileDelete'], 'file_rename' => $config['fileRename'], 'file_upload' => $config['fileUpload'], 'file_view' => $config['fileView'], 'folder_delete' => $config['folderDelete'], 'folder_rename' => $config['folderRename'], 'folder_create' => $config['folderCreate'], 'folder_view' => $config['folderView']));
             $container->setParameter('jonlil_ckfinder.baseDir', $config['baseDir']);
             break;
     }
     $container->setParameter('jonlil_ckfinder.license', array('key' => $config['license']['key'], 'name' => $config['license']['name']));
     $container->setParameter('jonlil_ckfinder.baseUrl', $config['baseUrl']);
     $container->setParameter('twig.form.resources', array_merge($container->getParameter('twig.form.resources'), array('JonlilCKFinderBundle:Form:ckfinder_widget.html.twig')));
 }

作者:gitter-badge    项目:OAuth2ServerBundl   
public function load(array $pluginConfiguration, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/Resources/config'));
     foreach (['services'] as $basename) {
         $loader->load(sprintf('%s.xml', $basename));
     }
 }

作者:placid200    项目:CraueFormFlowBundl   
/**
  * {@inheritDoc}
  */
 public function load(array $config, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('form_flow.xml');
     $loader->load('twig.xml');
     $loader->load('util.xml');
 }

作者:php-htt    项目:HttplugBundl   
/**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = $this->getConfiguration($configs, $container);
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $loader->load('plugins.xml');
     // Register default services
     foreach ($config['classes'] as $service => $class) {
         if (!empty($class)) {
             $container->register(sprintf('httplug.%s.default', $service), $class);
         }
     }
     // Set main aliases
     foreach ($config['main_alias'] as $type => $id) {
         $container->setAlias(sprintf('httplug.%s', $type), $id);
     }
     // Configure toolbar
     if ($this->isConfigEnabled($container, $config['profiling'])) {
         $loader->load('data-collector.xml');
         if (!empty($config['profiling']['formatter'])) {
             // Add custom formatter
             $container->getDefinition('httplug.collector.debug_collector')->replaceArgument(0, new Reference($config['profiling']['formatter']));
         }
         $container->getDefinition('httplug.formatter.full_http_message')->addArgument($config['profiling']['captured_body_length']);
     }
     $this->configureClients($container, $config);
     $this->configureSharedPlugins($container, $config['plugins']);
     // must be after clients, as clients.X.plugins might use plugins as templates that will be removed
     $this->configureAutoDiscoveryClients($container, $config);
 }

作者:krishnavelugul    项目:DoctrineEncryptBundl   
/**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $services = array('orm' => 'orm-services');
     $supportedEncryptorClasses = array('aes256' => 'VMelnik\\DoctrineEncryptBundle\\Encryptors\\AES256Encryptor');
     if (empty($config['secret_key'])) {
         if ($container->hasParameter('secret')) {
             $config['secret_key'] = $container->getParameter('secret');
         } else {
             throw new \RuntimeException('You must provide "secret_key" for DoctrineEncryptBundle or "secret" for framework');
         }
     }
     if (!empty($config['encryptor_class'])) {
         $encryptorFullName = $config['encryptor_class'];
     } else {
         $encryptorFullName = $supportedEncryptorClasses[$config['encryptor']];
     }
     $container->setParameter('vmelnik_doctrine_encrypt.encryptor_class_name', $encryptorFullName);
     $container->setParameter('vmelnik_doctrine_encrypt.secret_key', $config['secret_key']);
     if (!empty($config['encryptor_service'])) {
         $container->setParameter('vmelnik_doctrine_encrypt.encryptor_service', $config['encryptor_service']);
     }
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load(sprintf('%s.xml', $services[$config['db_driver']]));
 }

作者:Foil    项目:EoAirbrakeBundl   
/**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $container->setParameter('eo_airbrake.api_key', $config['api_key']);
     $container->setParameter('eo_airbrake.async', $config['async']);
     $container->setParameter('eo_airbrake.host', $config['host']);
     $container->setParameter('eo_airbrake.secure', $config['secure']);
     // Exception Listener
     if ($config['api_key']) {
         // Airbreak Configuration
         $class = $container->getParameter('eo_airbrake.configuration.class');
         $definition = new Definition($class, array($config['api_key'], $config['async'], $container->getParameter('kernel.environment'), $config['host'], $config['secure']));
         $container->setDefinition('eo_airbrake.configuration', $definition);
         // Airbreak Client
         $class = $container->getParameter('eo_airbrake.client.class');
         $definition = new Definition($class, array(new Reference('eo_airbrake.configuration')));
         $container->setDefinition('eo_airbrake.client', $definition);
         // Exception Listener
         $class = $container->getParameter('eo_airbrake.exception_listener.class');
         $definition = new Definition($class, array(new Reference('eo_airbrake.client'), $config['ignored_exceptions']));
         $definition->addTag('kernel.event_listener', array('event' => 'kernel.exception', 'method' => 'onKernelException'));
         $container->setDefinition('php_airbrake.exception_listener', $definition);
         // PHP Shutdown Listener
         $class = $container->getParameter('eo_airbrake.shutdown_listener.class');
         $definition = new Definition($class, array(new Reference('eo_airbrake.client')));
         $definition->addTag('kernel.event_listener', array('event' => 'kernel.controller', 'method' => 'register'));
         $container->setDefinition('php_airbrake.shutdown_listener', $definition);
     }
 }

作者:spf1    项目:symfon   
public function testDbalLoadFromXmlMultipleConnections()
 {
     $container = $this->getContainer();
     $loader = new DoctrineExtension();
     $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 = $this->getContainer();
     $loader = new DoctrineExtension();
     $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']);
 }

作者:johanderuijte    项目:BernardBundl   
protected function loadInternal(array $config, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $container->setAlias('bernard.driver', 'bernard.driver.' . $config['driver']);
     switch ($config['driver']) {
         case 'doctrine':
             $this->registerDoctrineConfiguration($config['options'], $container);
             break;
         case 'file':
             $this->registerFlatFileConfiguration($config['options'], $container);
             break;
         case 'phpamqp':
             $this->registerPhpAmqpConfiguration($config['options'], $container);
             break;
         case 'phpredis':
             $this->registerPhpRedisConfiguration($config['options'], $container);
             break;
         case 'predis':
             $this->registerPredisConfiguration($config['options'], $container);
             break;
         case 'ironmq':
             $this->registerIronMQConfiguration($config['options'], $container);
             break;
         case 'sqs':
             $this->registerSqsConfiguration($config['options'], $container);
             break;
     }
     $this->registerListeners($config['listeners'], $container);
 }

作者:inoxis9    项目:Symfony   
/**
  * 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']);
 }

作者:davidde    项目:mailcatche   
/**
  * {@inheritdoc}
  */
 public function load(ContainerBuilder $container, array $config)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/services'));
     $loader->load('core.xml');
     $container->setParameter('behat.mailcatcher.client.url', $config['url']);
     $container->setParameter('behat.mailcatcher.purge_before_scenario', $config['purge_before_scenario']);
 }

作者:hikmahtiar    项目:drafterbi   
public function loadInternal(array $config, ContainerBuilder $container)
 {
     $this->mergeNavigation($container, $config['navigation']);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     $loader->load('roles.xml');
 }

作者:zapoyo    项目:extraform-bundl   
/**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     // add custom form widgets
     $container->setParameter('twig.form.resources', array_merge($container->getParameter('twig.form.resources'), ['ZapoyokExtraFormBundle:Form:form_admin_fields.html.twig']));
 }

作者:hellovi    项目:symfon   
/**
  * 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);
 }

作者:NadirZenit    项目:famet   
/**
  * Loads a specific configuration.
  *
  * @param array            $config    An array of configuration values
  * @param ContainerBuilder $container A ContainerBuilder instance
  *
  * @throws \InvalidArgumentException When provided tag is not defined in this extension
  *
  * @api
  */
 public function load(array $config, ContainerBuilder $container)
 {
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('event_listeners.xml');
     $loader->load('serializer.xml');
     $loader->load('api_controllers.xml');
 }

作者:natxe    项目:JMSI18nRoutingBundl   
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');
     }
 }

作者:pigroup    项目:SfynxCaptchaBundl   
/**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $config = $this->processConfiguration(new Configuration(), $configs);
     $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('form.xml');
     $loader->load('manager.xml');
 }

作者:nicodm    项目:symfon   
/**
  * Responds to the twig 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('twig.xml');
     $configuration = $this->getConfiguration($configs, $container);
     $config = $this->processConfiguration($configuration, $configs);
     $container->setParameter('twig.exception_listener.controller', $config['exception_controller']);
     $container->setParameter('twig.form.resources', $config['form']['resources']);
     $reflClass = new \ReflectionClass('Symfony\\Bridge\\Twig\\Extension\\FormExtension');
     $container->getDefinition('twig.loader')->addMethodCall('addPath', array(dirname(dirname($reflClass->getFileName())) . '/Resources/views/Form'));
     if (!empty($config['globals'])) {
         $def = $container->getDefinition('twig');
         foreach ($config['globals'] as $key => $global) {
             if (isset($global['type']) && 'service' === $global['type']) {
                 $def->addMethodCall('addGlobal', array($key, new Reference($global['id'])));
             } else {
                 $def->addMethodCall('addGlobal', array($key, $global['value']));
             }
         }
     }
     unset($config['form'], $config['globals'], $config['extensions']);
     $container->setParameter('twig.options', $config);
     if ($container->getParameter('kernel.debug')) {
         $loader->load('debug.xml');
         $container->setDefinition('templating.engine.twig', $container->findDefinition('debug.templating.engine.twig'));
         $container->setAlias('debug.templating.engine.twig', 'templating.engine.twig');
     }
     $this->addClassesToCompile(array('Twig_Environment', 'Twig_ExtensionInterface', 'Twig_Extension', 'Twig_Extension_Core', 'Twig_Extension_Escaper', 'Twig_Extension_Optimizer', 'Twig_LoaderInterface', 'Twig_Markup', 'Twig_TemplateInterface', 'Twig_Template'));
 }

作者:shiva    项目:bouncer-bundl   
/**
  * {@inheritdoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('services.xml');
     // load db_driver container configuration
     $loader->load(sprintf('%s.xml', $config['db_driver']));
     if ($config['filter']['enabled']) {
         // if enabled - define filter
         $loader->load('filter.xml');
         $mailers = $config['filter']['mailer_name'];
         $filter = $container->getDefinition('shivas_bouncer.swift_mailer.filter');
         foreach ($mailers as $mailer) {
             $filter->addTag(sprintf('swiftmailer.%s.plugin', $mailer));
         }
     }
     $container->setParameter(sprintf('shivas_bouncer.backend_%s', $config['db_driver']), true);
     $container->setParameter('shivas_bouncer.driver', $config['db_driver']);
     $container->setParameter('shivas_bouncer.manager_name', $config['model_manager_name']);
     $container->setParameter('shivas_bouncer.bounce_endpoint', $config['bounce_endpoint']);
     $container->setParameter('shivas_bouncer.filter', $config['filter']);
     $container->setParameter('shivas_bouncer.filter.filter_not_permanent', $config['filter']['filter_not_permanent']);
     $container->setParameter('shivas_bouncer.aws_api_key', $config['aws_api_key']);
 }

作者:rdohm    项目:MopaBootstrapBundl   
protected function loadExamples(ContainerBuilder $container)
 {
     $xmlloader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/examples'));
     $yamlloader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/examples'));
     $yamlloader->load("example_menu.yml");
     $xmlloader->load("example_navbar.xml");
 }

作者:nicolasdewe    项目:events-bundl   
/**
  * {@inheritDoc}
  */
 public function load(array $configs, ContainerBuilder $container)
 {
     $configuration = new Configuration();
     $config = $this->processConfiguration($configuration, $configs);
     $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
     $loader->load('connectors.xml');
     $loader->load('services.xml');
     // Listen service
     $container->getDefinition('ndewez.events.listener')->addArgument($config['events']);
     // Connector mock
     if (true === $config['mock']) {
         $this->setConnector($container, $container->getDefinition('ndewez.events.connector.mock'));
         return;
     }
     if (!isset($config['connection'])) {
         return;
     }
     // Connector synchronous
     if (ConnectorInterface::MODE_SYNCH === $config['mode']) {
         $connector = $container->getDefinition('ndewez.events.connector.http');
         $connector->replaceArgument(0, $config['connection']['host']);
         $this->setConnector($container, $connector);
         return;
     }
     // Connector asynchronous
     $connector = $container->getDefinition('ndewez.events.connector.amqp');
     $connector->replaceArgument(0, $config['connection']['host'])->replaceArgument(1, $config['connection']['port'])->replaceArgument(2, $config['connection']['user'])->replaceArgument(3, $config['connection']['password'])->replaceArgument(4, $config['connection']['application_code']);
     $this->setConnector($container, $connector);
 }


问题


面经


文章

微信
公众号

扫码关注公众号