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


PHP BuilderConfiguration::findDefinition方法代码示例

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


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

示例1: 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]);
             }
         }
     }
     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')));
     }
     $configuration->setAlias('mailer', 'swiftmailer.mailer');
     return $configuration;
 }
开发者ID:poulikov,项目名称:readlater,代码行数:61,代码来源:SwiftmailerExtension.php

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

示例3: 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:kdambekalns,项目名称:framework-benchs,代码行数:43,代码来源:WebExtension.php

示例4: Definition

$configuration->setDefinition('foobar', $foo = new Definition('FooBarClass'));
$t->is($configuration->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined');
$t->ok($configuration->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference');

$configuration->addDefinitions($defs = array('foobar' => new Definition('FooBarClass')));
$t->is($configuration->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions');

try
{
  $configuration->getDefinition('baz');
  $t->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
}
catch (InvalidArgumentException $e)
{
  $t->pass('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
}

// ->findDefinition()
$t->diag('->findDefinition()');
$configuration = new BuilderConfiguration(array('foo' => $definition = new Definition('FooClass')));
$configuration->setAlias('bar', 'foo');
$configuration->setAlias('foobar', 'bar');
$t->is($configuration->findDefinition('foobar'), $definition, '->findDefinition() returns a Definition');

// ->addResource() ->getResources()
$t->diag('->addResource() ->getResources()');
$configuration = new BuilderConfiguration();
$configuration->addResource($a = new FileResource('foo.xml'));
$configuration->addResource($b = new FileResource('foo.yml'));
$t->is($configuration->getResources(), array($a, $b), '->getResources() returns an array of resources read for the current configuration');
开发者ID:nicolasmartin,项目名称:symfony,代码行数:30,代码来源:BuilderConfigurationTest.php

示例5: testFindDefinition

 public function testFindDefinition()
 {
     $configuration = new BuilderConfiguration(array('foo' => $definition = new Definition('FooClass')));
     $configuration->setAlias('bar', 'foo');
     $configuration->setAlias('foobar', 'bar');
     $this->assertEquals($definition, $configuration->findDefinition('foobar'), '->findDefinition() returns a Definition');
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:7,代码来源:BuilderConfigurationTest.php


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