本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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');
}
示例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;
}
示例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]);
}
}
}
示例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;
}
示例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;
}
示例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));
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}