當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BuilderConfiguration::merge方法代碼示例

本文整理匯總了PHP中Symfony\Components\DependencyInjection\BuilderConfiguration::merge方法的典型用法代碼示例。如果您正苦於以下問題:PHP BuilderConfiguration::merge方法的具體用法?PHP BuilderConfiguration::merge怎麽用?PHP BuilderConfiguration::merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Components\DependencyInjection\BuilderConfiguration的用法示例。


在下文中一共展示了BuilderConfiguration::merge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: buildContainer

 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;
 }
開發者ID:Austin-Pray,項目名稱:lichess,代碼行數:8,代碼來源:Bundle.php

示例2: configLoad

 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;
 }
開發者ID:CodingFabian,項目名稱:symfony,代碼行數:10,代碼來源:ProfilerExtension.php

示例3: buildContainer

 /**
  * 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;
 }
開發者ID:poulikov,項目名稱:symfony,代碼行數:19,代碼來源:KernelBundle.php

示例4: execute

 /**
  * @see Command
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $kernel = $this->container->getKernelService();
     $container = new Builder($kernel->getDefaultParameters());
     $configuration = new BuilderConfiguration();
     foreach ($kernel->getBundles() as $bundle) {
         $configuration->merge($bundle->buildContainer($container));
     }
     $configuration->merge($kernel->registerContainerConfiguration());
     $container->merge($configuration);
     $kernel->optimizeContainer($container);
     $container->setService('kernel', $kernel);
     $dumper = new GraphvizDumper($container);
     $output->write($dumper->dump(), Output::OUTPUT_RAW);
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:18,代碼來源:ContainerGraphvizCommand.php

示例5: testMerge

 public function testMerge()
 {
     $configuration = new BuilderConfiguration();
     $configuration->merge(null);
     $this->assertEquals(array(), $configuration->getParameters(), '->merge() accepts null as an argument');
     $this->assertEquals(array(), $configuration->getDefinitions(), '->merge() accepts null as an argument');
     $configuration = new BuilderConfiguration(array(), array('bar' => 'foo'));
     $configuration1 = new BuilderConfiguration(array(), array('foo' => 'bar'));
     $configuration->merge($configuration1);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $configuration->getParameters(), '->merge() merges current parameters with the loaded ones');
     $configuration = new BuilderConfiguration(array(), array('bar' => 'foo', 'foo' => 'baz'));
     $config = new BuilderConfiguration(array(), array('foo' => 'bar'));
     $configuration->merge($config);
     $this->assertEquals(array('bar' => 'foo', 'foo' => 'bar'), $configuration->getParameters(), '->merge() overrides existing parameters');
     $configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass'), 'bar' => new Definition('BarClass')));
     $config = new BuilderConfiguration(array('baz' => new Definition('BazClass')));
     $config->setAlias('alias_for_foo', 'foo');
     $configuration->merge($config);
     $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($configuration->getDefinitions()), '->merge() merges definitions already defined ones');
     $this->assertEquals(array('alias_for_foo' => 'foo'), $configuration->getAliases(), '->merge() registers defined aliases');
     $configuration = new BuilderConfiguration(array('foo' => new Definition('FooClass')));
     $config->setDefinition('foo', new Definition('BazClass'));
     $configuration->merge($config);
     $this->assertEquals('BazClass', $configuration->getDefinition('foo')->getClass(), '->merge() overrides already defined services');
     $configuration = new BuilderConfiguration();
     $configuration->addResource($a = new FileResource('foo.xml'));
     $config = new BuilderConfiguration();
     $config->addResource($b = new FileResource('foo.yml'));
     $configuration->merge($config);
     $this->assertEquals(array($a, $b), $configuration->getResources(), '->merge() merges resources');
 }
開發者ID:jacques-sounvi,項目名稱:addressbook,代碼行數:31,代碼來源:BuilderConfigurationTest.php

示例6: ormLoad

 /**
  * 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;
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:14,代碼來源:DoctrineExtension.php

示例7: mongodbLoad

 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]);
         }
     }
 }
開發者ID:klaasn,項目名稱:symfony-sandbox,代碼行數:25,代碼來源:MongoDBExtension.php

示例8: sessionLoad

 /**
  * 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;
 }
開發者ID:bill97420,項目名稱:symfony,代碼行數:34,代碼來源:KernelExtension.php

示例9: configLoad

 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;
 }
開發者ID:poulikov,項目名稱:symfony,代碼行數:8,代碼來源:TwigExtension.php

示例10: configLoad

 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));
 }
開發者ID:klaasn,項目名稱:symfony-sandbox,代碼行數:8,代碼來源:TwigExtension.php

示例11: testLoad

 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;
 }
開發者ID:pgodel,項目名稱:PageRoller,代碼行數:8,代碼來源:KernelExtension.php

示例12: debugLoad

 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;
 }
開發者ID:kdambekalns,項目名稱:framework-benchs,代碼行數:18,代碼來源:WebExtension.php

示例13: odmLoad

 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;
 }
開發者ID:poulikov,項目名稱:MongoDBBundle,代碼行數:10,代碼來源:MongoExtension.php

示例14: mailerLoad

 /**
  * 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;
 }
開發者ID:pgodel,項目名稱:PageRoller,代碼行數:68,代碼來源:SwiftmailerExtension.php

示例15: loggerLoad

 /**
  * 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;
 }
開發者ID:robo47,項目名稱:symfony,代碼行數:25,代碼來源:ZendExtension.php


注:本文中的Symfony\Components\DependencyInjection\BuilderConfiguration::merge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。