当前位置: 首页>>代码示例>>PHP>>正文


PHP BuilderConfiguration::setParameter方法代码示例

本文整理汇总了PHP中Symfony\Components\DependencyInjection\BuilderConfiguration::setParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP BuilderConfiguration::setParameter方法的具体用法?PHP BuilderConfiguration::setParameter怎么用?PHP BuilderConfiguration::setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Components\DependencyInjection\BuilderConfiguration的用法示例。


在下文中一共展示了BuilderConfiguration::setParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: barLoad

 public function barLoad(array $config, BuilderConfiguration $configuration)
 {
     $configuration->setDefinition('project.service.bar', new Definition('FooClass'));
     $configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');
     $configuration->setDefinition('project.service.foo', new Definition('FooClass'));
     $configuration->setParameter('project.parameter.foo', isset($config['foo']) ? $config['foo'] : 'foobar');
     return $configuration;
 }
开发者ID:jarosz,项目名称:symfony,代码行数:8,代码来源:ProjectExtension.php

示例2: 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

示例3: 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

示例4: configLoad

 /**
  * Loads the Propel configuration.
  *
  * @param array $config A configuration array
  *
  * @return BuilderConfiguration A BuilderConfiguration instance
  */
 public function configLoad($config)
 {
     if (!isset($config['path'])) {
         throw new \InvalidArgumentException('The "path" parameter is mandatory.');
     }
     $configuration = new BuilderConfiguration();
     $configuration->setParameter('propel.path', $config['path']);
     if (isset($config['phing_path'])) {
         $configuration->setParameter('propel.phing_path', $config['phing_path']);
     }
     return $configuration;
 }
开发者ID:poulikov,项目名称:symfony,代码行数:19,代码来源:PropelExtension.php

示例5: 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

示例6: loggerLoad

 /**
  * 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']);
     }
 }
开发者ID:klaasn,项目名称:symfony-sandbox,代码行数:26,代码来源:ZendExtension.php

示例7: testSetGetParameter

 public function testSetGetParameter()
 {
     $configuration = new BuilderConfiguration(array(), array('foo' => 'bar'));
     $configuration->setParameter('bar', 'foo');
     $this->assertEquals($configuration->getParameter('bar'), 'foo', '->setParameter() sets the value of a new parameter');
     $configuration->setParameter('foo', 'baz');
     $this->assertEquals($configuration->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter');
     $configuration->setParameter('Foo', 'baz1');
     $this->assertEquals($configuration->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase');
     $this->assertEquals($configuration->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase');
     try {
         $configuration->getParameter('baba');
         $this->fail('->getParameter() throws an \\InvalidArgumentException if the key does not exist');
     } catch (\InvalidArgumentException $e) {
     }
 }
开发者ID:CodingFabian,项目名称:symfony,代码行数:16,代码来源:BuilderConfigurationTest.php

示例8: 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

示例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: configLoad

 public function configLoad($config, BuilderConfiguration $configuration)
 {
     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\\HttpKernel\\HttpKernel', 'Symfony\\Components\\HttpKernel\\Request', 'Symfony\\Components\\HttpKernel\\Response', 'Symfony\\Components\\HttpKernel\\ResponseListener', '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\\FrameworkBundle\\RequestListener', 'Symfony\\Framework\\FrameworkBundle\\Controller', 'Symfony\\Framework\\FrameworkBundle\\Controller\\ControllerLoaderListener', 'Symfony\\Framework\\FrameworkBundle\\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;
 }
开发者ID:klaasn,项目名称:symfony-sandbox,代码行数:21,代码来源:KernelExtension.php

示例12: 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)
 {
     $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;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:54,代码来源:SwiftmailerExtension.php

示例13: dbalLoad

 /**
  * Loads the DBAL configuration.
  *
  * Usage example:
  *
  *      <doctrine:dbal dbname="sfweb" username="root" />
  *
  * @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['dbal']));
     foreach (array('dbname', 'host', 'username', 'password', 'path', 'port') as $key) {
         if (isset($config[$key])) {
             $configuration->setParameter('doctrine.dbal.' . $key, $config[$key]);
         }
     }
     if (isset($config['options'])) {
         $configuration->setParameter('doctrine.dbal.driver.options', $config['options']);
     }
     if (isset($config['driver'])) {
         $class = $config['driver'];
         if (in_array($class, array('OCI8', 'PDOMsSql', 'PDOMySql', 'PDOOracle', 'PDOPgSql', 'PDOSqlite'))) {
             $class = 'Doctrine\\DBAL\\Driver\\' . $class . '\\Driver';
         }
         $configuration->setParameter('doctrine.dbal.driver.class', $class);
     }
     $configuration->setAlias('database_connection', null !== $this->alias ? $this->alias : 'doctrine.dbal.connection');
     return $configuration;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:34,代码来源:DoctrineExtension.php

示例14: configLoad

 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;
 }
开发者ID:pablosik,项目名称:symfony,代码行数:24,代码来源:bootstrap.php

示例15: templatingLoad

 /**
  * 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;
 }
开发者ID:CodingFabian,项目名称:symfony,代码行数:43,代码来源:WebExtension.php


注:本文中的Symfony\Components\DependencyInjection\BuilderConfiguration::setParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。